xref: /titanic_51/usr/src/uts/i86pc/io/consplat.c (revision 93a18d6d401e844455263f926578e9d2aa6b47ec)
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 /*
23*93a18d6dSEnrico Perla - Sun Microsystems  * Copyright 2010 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 
194*93a18d6dSEnrico Perla - Sun Microsystems /*
195*93a18d6dSEnrico Perla - Sun Microsystems  * NOTE: this function is duplicated here and in gfx_private/vgatext while
196*93a18d6dSEnrico Perla - Sun Microsystems  *       we work on a set of commitable interfaces to sunpci.c.
197*93a18d6dSEnrico Perla - Sun Microsystems  *
198*93a18d6dSEnrico Perla - Sun Microsystems  * Use the class code to determine if the device is a PCI-to-PCI bridge.
199*93a18d6dSEnrico Perla - Sun Microsystems  * Returns:  B_TRUE  if the device is a bridge.
200*93a18d6dSEnrico Perla - Sun Microsystems  *           B_FALSE if the device is not a bridge or the property cannot be
201*93a18d6dSEnrico Perla - Sun Microsystems  *		     retrieved.
202*93a18d6dSEnrico Perla - Sun Microsystems  */
203*93a18d6dSEnrico Perla - Sun Microsystems static boolean_t
204*93a18d6dSEnrico Perla - Sun Microsystems is_pci_bridge(dev_info_t *dip)
205*93a18d6dSEnrico Perla - Sun Microsystems {
206*93a18d6dSEnrico Perla - Sun Microsystems 	uint32_t class_code;
207*93a18d6dSEnrico Perla - Sun Microsystems 
208*93a18d6dSEnrico Perla - Sun Microsystems 	class_code = (uint32_t)ddi_prop_get_int(DDI_DEV_T_ANY, dip,
209*93a18d6dSEnrico Perla - Sun Microsystems 	    DDI_PROP_DONTPASS, "class-code", 0xffffffff);
210*93a18d6dSEnrico Perla - Sun Microsystems 
211*93a18d6dSEnrico Perla - Sun Microsystems 	if (class_code == 0xffffffff || class_code == DDI_PROP_NOT_FOUND)
212*93a18d6dSEnrico Perla - Sun Microsystems 		return (B_FALSE);
213*93a18d6dSEnrico Perla - Sun Microsystems 
214*93a18d6dSEnrico Perla - Sun Microsystems 	class_code &= 0x00ffff00;
215*93a18d6dSEnrico Perla - Sun Microsystems 	if (class_code == ((PCI_CLASS_BRIDGE << 16) | (PCI_BRIDGE_PCI << 8)))
216*93a18d6dSEnrico Perla - Sun Microsystems 		return (B_TRUE);
217*93a18d6dSEnrico Perla - Sun Microsystems 
218*93a18d6dSEnrico Perla - Sun Microsystems 	return (B_FALSE);
219*93a18d6dSEnrico Perla - Sun Microsystems }
220*93a18d6dSEnrico Perla - Sun Microsystems 
22145e46d06Srui zang - Sun Microsystems - Beijing China static int
22245e46d06Srui zang - Sun Microsystems - Beijing China find_fb_dev(dev_info_t *dip, void *found_dip)
22345e46d06Srui zang - Sun Microsystems - Beijing China {
22445e46d06Srui zang - Sun Microsystems - Beijing China 	char *dev_type;
22545e46d06Srui zang - Sun Microsystems - Beijing China 	dev_info_t *pdip;
22645e46d06Srui zang - Sun Microsystems - Beijing China 	char *parent_type;
22745e46d06Srui zang - Sun Microsystems - Beijing China 
22845e46d06Srui zang - Sun Microsystems - Beijing China 	if (dip == ddi_root_node())
22945e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_CONTINUE);
23045e46d06Srui zang - Sun Microsystems - Beijing China 
23145e46d06Srui zang - Sun Microsystems - Beijing China 	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
23245e46d06Srui zang - Sun Microsystems - Beijing China 	    "device_type", &dev_type) != DDI_SUCCESS)
23345e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
23445e46d06Srui zang - Sun Microsystems - Beijing China 
23545e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(dev_type, "isa") == 0) || (strcmp(dev_type, "eisa") == 0)) {
23645e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(dev_type);
23745e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_CONTINUE);
23845e46d06Srui zang - Sun Microsystems - Beijing China 	}
23945e46d06Srui zang - Sun Microsystems - Beijing China 
24045e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(dev_type, "pci") == 0) ||
24145e46d06Srui zang - Sun Microsystems - Beijing China 	    (strcmp(dev_type, "pciex") == 0)) {
24245e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_acc_handle_t pci_conf;
24345e46d06Srui zang - Sun Microsystems - Beijing China 		uint16_t data16;
244c401c7a8Srui zang - Sun Microsystems - Beijing China 		char *nodename;
24545e46d06Srui zang - Sun Microsystems - Beijing China 
24645e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(dev_type);
24745e46d06Srui zang - Sun Microsystems - Beijing China 
248c401c7a8Srui zang - Sun Microsystems - Beijing China 		nodename = ddi_node_name(dip);
24945e46d06Srui zang - Sun Microsystems - Beijing China 
250*93a18d6dSEnrico Perla - Sun Microsystems 		/*
251*93a18d6dSEnrico Perla - Sun Microsystems 		 * If the node is not a PCI-to-PCI bridge, continue traversing
252*93a18d6dSEnrico Perla - Sun Microsystems 		 * (it could be the root node), otherwise, check for the
253*93a18d6dSEnrico Perla - Sun Microsystems 		 * VGAEnable bit to be set in the Bridge Control Register.
254*93a18d6dSEnrico Perla - Sun Microsystems 		 */
255c401c7a8Srui zang - Sun Microsystems - Beijing China 		if (strcmp(nodename, "pci") == 0) {
256*93a18d6dSEnrico Perla - Sun Microsystems 			if (is_pci_bridge(dip) == B_FALSE)
25745e46d06Srui zang - Sun Microsystems - Beijing China 				return (DDI_WALK_CONTINUE);
25845e46d06Srui zang - Sun Microsystems - Beijing China 		}
25945e46d06Srui zang - Sun Microsystems - Beijing China 
260c401c7a8Srui zang - Sun Microsystems - Beijing China 		if (i_ddi_attach_node_hierarchy(dip) != DDI_SUCCESS)
261c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
262c401c7a8Srui zang - Sun Microsystems - Beijing China 
263c401c7a8Srui zang - Sun Microsystems - Beijing China 		if (pci_config_setup(dip, &pci_conf) != DDI_SUCCESS)
264c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
265c401c7a8Srui zang - Sun Microsystems - Beijing China 
26645e46d06Srui zang - Sun Microsystems - Beijing China 		data16 = pci_config_get16(pci_conf, PCI_BCNF_BCNTRL);
26745e46d06Srui zang - Sun Microsystems - Beijing China 		pci_config_teardown(&pci_conf);
26845e46d06Srui zang - Sun Microsystems - Beijing China 
26945e46d06Srui zang - Sun Microsystems - Beijing China 		if (data16 & PCI_BCNF_BCNTRL_VGA_ENABLE)
27045e46d06Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_CONTINUE);
27145e46d06Srui zang - Sun Microsystems - Beijing China 
27245e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
27345e46d06Srui zang - Sun Microsystems - Beijing China 	}
27445e46d06Srui zang - Sun Microsystems - Beijing China 
27545e46d06Srui zang - Sun Microsystems - Beijing China 	if (strcmp(dev_type, "display") != 0) {
27645e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(dev_type);
27745e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_CONTINUE);
27845e46d06Srui zang - Sun Microsystems - Beijing China 	}
27945e46d06Srui zang - Sun Microsystems - Beijing China 
28045e46d06Srui zang - Sun Microsystems - Beijing China 	ddi_prop_free(dev_type);
28145e46d06Srui zang - Sun Microsystems - Beijing China 
28245e46d06Srui zang - Sun Microsystems - Beijing China 	if ((pdip = ddi_get_parent(dip)) == NULL)
283c401c7a8Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
28445e46d06Srui zang - Sun Microsystems - Beijing China 
28545e46d06Srui zang - Sun Microsystems - Beijing China 	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, pdip, DDI_PROP_DONTPASS,
28645e46d06Srui zang - Sun Microsystems - Beijing China 	    "device_type", &parent_type) != DDI_SUCCESS)
287c401c7a8Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
28845e46d06Srui zang - Sun Microsystems - Beijing China 
28945e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(parent_type, "isa") == 0) ||
29045e46d06Srui zang - Sun Microsystems - Beijing China 	    (strcmp(parent_type, "eisa") == 0)) {
29145e46d06Srui zang - Sun Microsystems - Beijing China 		*(dev_info_t **)found_dip = dip;
29245e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(parent_type);
29345e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_TERMINATE);
29445e46d06Srui zang - Sun Microsystems - Beijing China 	}
29545e46d06Srui zang - Sun Microsystems - Beijing China 
29645e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(parent_type, "pci") == 0) ||
29745e46d06Srui zang - Sun Microsystems - Beijing China 	    (strcmp(parent_type, "pciex") == 0)) {
29845e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_acc_handle_t pci_conf;
29945e46d06Srui zang - Sun Microsystems - Beijing China 		uint16_t data16;
30045e46d06Srui zang - Sun Microsystems - Beijing China 
30145e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(parent_type);
30245e46d06Srui zang - Sun Microsystems - Beijing China 
30345e46d06Srui zang - Sun Microsystems - Beijing China 		if (i_ddi_attach_node_hierarchy(dip) != DDI_SUCCESS)
304c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
30545e46d06Srui zang - Sun Microsystems - Beijing China 
30645e46d06Srui zang - Sun Microsystems - Beijing China 		if (pci_config_setup(dip, &pci_conf) != DDI_SUCCESS)
307c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
30845e46d06Srui zang - Sun Microsystems - Beijing China 
30945e46d06Srui zang - Sun Microsystems - Beijing China 		data16 = pci_config_get16(pci_conf, PCI_CONF_COMM);
31045e46d06Srui zang - Sun Microsystems - Beijing China 		pci_config_teardown(&pci_conf);
31145e46d06Srui zang - Sun Microsystems - Beijing China 
31245e46d06Srui zang - Sun Microsystems - Beijing China 		if (!(data16 & PCI_COMM_IO))
313c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
31445e46d06Srui zang - Sun Microsystems - Beijing China 
31545e46d06Srui zang - Sun Microsystems - Beijing China 		*(dev_info_t **)found_dip = dip;
31645e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_TERMINATE);
31745e46d06Srui zang - Sun Microsystems - Beijing China 	}
31845e46d06Srui zang - Sun Microsystems - Beijing China 
31945e46d06Srui zang - Sun Microsystems - Beijing China 	ddi_prop_free(parent_type);
320c401c7a8Srui zang - Sun Microsystems - Beijing China 	return (DDI_WALK_PRUNECHILD);
32145e46d06Srui zang - Sun Microsystems - Beijing China }
32245e46d06Srui zang - Sun Microsystems - Beijing China 
323ae115bc7Smrj /*
32445e46d06Srui zang - Sun Microsystems - Beijing China  * Conduct a width-first traverse searching for a display device which
32545e46d06Srui zang - Sun Microsystems - Beijing China  * has either:
32645e46d06Srui zang - Sun Microsystems - Beijing China  * 1) a VGA device.
32745e46d06Srui zang - Sun Microsystems - Beijing China  * 2) a PCI VGA compatible device whose IO space is enabled
32845e46d06Srui zang - Sun Microsystems - Beijing China  *    and the VGA Enable bit of any PCI-PCI bridge above it is set.
32945e46d06Srui zang - Sun Microsystems - Beijing China  *
33045e46d06Srui zang - Sun Microsystems - Beijing China  * Return the device path as the console fb path.
331ae115bc7Smrj  */
332ae115bc7Smrj char *
333ae115bc7Smrj plat_fbpath(void)
334ae115bc7Smrj {
33545e46d06Srui zang - Sun Microsystems - Beijing China 	dev_info_t *fb_dip = NULL;
336ae115bc7Smrj 	static char *fbpath = NULL;
337ae115bc7Smrj 	static char fbpath_buf[MAXPATHLEN];
338ae115bc7Smrj 
33945e46d06Srui zang - Sun Microsystems - Beijing China 	ddi_walk_devs(ddi_root_node(), find_fb_dev, &fb_dip);
340843e1988Sjohnlev 
34145e46d06Srui zang - Sun Microsystems - Beijing China 	if (fb_dip == NULL)
34245e46d06Srui zang - Sun Microsystems - Beijing China 		return (NULL);
343843e1988Sjohnlev 
34445e46d06Srui zang - Sun Microsystems - Beijing China 	(void) ddi_pathname(fb_dip, fbpath_buf);
345ae115bc7Smrj 	fbpath = fbpath_buf;
346ae115bc7Smrj 
347843e1988Sjohnlev 	return (fbpath);
348ae115bc7Smrj }
349ae115bc7Smrj 
350ae115bc7Smrj char *
351ae115bc7Smrj plat_mousepath(void)
352ae115bc7Smrj {
35378323854SJudy Chen 	static char mpath[MAXPATHLEN];
35478323854SJudy Chen 
355ae115bc7Smrj 	/*
356ae115bc7Smrj 	 * Hardcode to isa mouse path
357ae115bc7Smrj 	 * XXX make it settable via bootprop?
358ae115bc7Smrj 	 */
35978323854SJudy Chen 	if (pseudo_isa)
360ae115bc7Smrj 		return ("/isa/i8042@1,60/mouse@1");
36178323854SJudy Chen 
36278323854SJudy Chen 	if (plat_devpath("mouse8042", mpath) == NULL)
36378323854SJudy Chen 		return (NULL);
36478323854SJudy Chen 
36578323854SJudy Chen 	return (mpath);
366ae115bc7Smrj }
367ae115bc7Smrj 
368ae115bc7Smrj /* return path of first usb serial device */
369ae115bc7Smrj static char *
370ae115bc7Smrj plat_usbser_path(void)
371ae115bc7Smrj {
372ae115bc7Smrj 	extern dev_info_t *usbser_first_device(void);
373ae115bc7Smrj 
374ae115bc7Smrj 	dev_info_t *us_dip;
375ae115bc7Smrj 	static char *us_path = NULL;
376ae115bc7Smrj 
377ae115bc7Smrj 	if (us_path)
378ae115bc7Smrj 		return (us_path);
379ae115bc7Smrj 
380ae115bc7Smrj 	us_dip = usbser_first_device();
381ae115bc7Smrj 	if (us_dip == NULL)
382ae115bc7Smrj 		return (NULL);
383ae115bc7Smrj 
384ae115bc7Smrj 	us_path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
385ae115bc7Smrj 	(void) ddi_pathname(us_dip, us_path);
386ae115bc7Smrj 	ndi_rele_devi(us_dip);	/* held from usbser_first_device */
387ae115bc7Smrj 	return (us_path);
388ae115bc7Smrj }
389ae115bc7Smrj 
39078323854SJudy Chen static char *
39178323854SJudy Chen plat_ttypath(int inum)
39278323854SJudy Chen {
39378323854SJudy Chen 	static char *defaultpath[] = {
39478323854SJudy Chen 	    "/isa/asy@1,3f8:a",
39578323854SJudy Chen 	    "/isa/asy@1,2f8:b"
39678323854SJudy Chen 	};
39778323854SJudy Chen 	static char path[MAXPATHLEN];
39878323854SJudy Chen 	char *bp;
39978323854SJudy Chen 	major_t major;
40078323854SJudy Chen 	dev_info_t *dip;
40178323854SJudy Chen 
40278323854SJudy Chen 	if (pseudo_isa)
40378323854SJudy Chen 		return (defaultpath[inum]);
40478323854SJudy Chen 
40578323854SJudy Chen 	if ((major = ddi_name_to_major("asy")) == (major_t)-1)
40678323854SJudy Chen 		return (NULL);
40778323854SJudy Chen 
40878323854SJudy Chen 	if ((dip = devnamesp[major].dn_head) == NULL)
40978323854SJudy Chen 		return (NULL);
41078323854SJudy Chen 
41101457ffdSJudy Chen 	for (; dip != NULL; dip = ddi_get_next(dip)) {
41278323854SJudy Chen 		if (i_ddi_attach_node_hierarchy(dip) != DDI_SUCCESS)
41378323854SJudy Chen 			return (NULL);
41478323854SJudy Chen 
41501457ffdSJudy Chen 		if (DEVI(dip)->devi_minor->ddm_name[0] == ('a' + (char)inum))
41601457ffdSJudy Chen 			break;
41701457ffdSJudy Chen 	}
41801457ffdSJudy Chen 	if (dip == NULL)
41901457ffdSJudy Chen 		return (NULL);
42001457ffdSJudy Chen 
42178323854SJudy Chen 	(void) ddi_pathname(dip, path);
42278323854SJudy Chen 	bp = path + strlen(path);
42378323854SJudy Chen 	(void) snprintf(bp, 3, ":%s", DEVI(dip)->devi_minor->ddm_name);
42478323854SJudy Chen 
42578323854SJudy Chen 	return (path);
42678323854SJudy Chen }
42778323854SJudy Chen 
428ae115bc7Smrj /*
429ae115bc7Smrj  * Lacking support for com2 and com3, if that matters.
430ae115bc7Smrj  * Another possible enhancement could be to use properties
431ae115bc7Smrj  * for the port mapping rather than simply hard-code them.
432ae115bc7Smrj  */
433ae115bc7Smrj char *
434ae115bc7Smrj plat_stdinpath(void)
435ae115bc7Smrj {
436ae115bc7Smrj 	switch (console_type()) {
437843e1988Sjohnlev #if defined(__xpv)
438843e1988Sjohnlev 	case CONS_HYPERVISOR:
439843e1988Sjohnlev 		return ("/xpvd/xencons@0");
440843e1988Sjohnlev #endif /* __xpv */
441ae115bc7Smrj 	case CONS_TTYA:
44278323854SJudy Chen 		return (plat_ttypath(0));
443ae115bc7Smrj 	case CONS_TTYB:
44478323854SJudy Chen 		return (plat_ttypath(1));
445ae115bc7Smrj 	case CONS_USBSER:
446ae115bc7Smrj 		return (plat_usbser_path());
447ae115bc7Smrj 	case CONS_SCREEN:
448ae115bc7Smrj 	default:
449ae115bc7Smrj 		break;
450ae115bc7Smrj 	};
451ae115bc7Smrj 	return (plat_kbdpath());
452ae115bc7Smrj }
453ae115bc7Smrj 
454ae115bc7Smrj char *
455ae115bc7Smrj plat_stdoutpath(void)
456ae115bc7Smrj {
457ae115bc7Smrj 	switch (console_type()) {
458843e1988Sjohnlev #if defined(__xpv)
459843e1988Sjohnlev 	case CONS_HYPERVISOR:
460843e1988Sjohnlev 		return ("/xpvd/xencons@0");
461843e1988Sjohnlev #endif /* __xpv */
462ae115bc7Smrj 	case CONS_TTYA:
46378323854SJudy Chen 		return (plat_ttypath(0));
464ae115bc7Smrj 	case CONS_TTYB:
46578323854SJudy Chen 		return (plat_ttypath(1));
466ae115bc7Smrj 	case CONS_USBSER:
467ae115bc7Smrj 		return (plat_usbser_path());
468ae115bc7Smrj 	case CONS_SCREEN:
469ae115bc7Smrj 	default:
470ae115bc7Smrj 		break;
471ae115bc7Smrj 	};
472ae115bc7Smrj 	return (plat_fbpath());
473ae115bc7Smrj }
474ae115bc7Smrj 
475ae115bc7Smrj /*
476ae115bc7Smrj  * If VIS_PIXEL mode will be implemented on x86, these following
477ae115bc7Smrj  * functions should be re-considered. Now these functions are
478ae115bc7Smrj  * unused on x86.
479ae115bc7Smrj  */
480ae115bc7Smrj void
481c9503a49Slq150181 plat_tem_get_inverses(int *inverse, int *inverse_screen)
482c9503a49Slq150181 {
483c9503a49Slq150181 	*inverse = 0;
484c9503a49Slq150181 	*inverse_screen = 0;
485c9503a49Slq150181 }
486c9503a49Slq150181 
487c9503a49Slq150181 void
488ae115bc7Smrj plat_tem_get_prom_font_size(int *charheight, int *windowtop)
489ae115bc7Smrj {
490ae115bc7Smrj 	*charheight = 0;
491ae115bc7Smrj 	*windowtop = 0;
492ae115bc7Smrj }
493ae115bc7Smrj 
494843e1988Sjohnlev /*ARGSUSED*/
495ae115bc7Smrj void
496ae115bc7Smrj plat_tem_get_prom_size(size_t *height, size_t *width)
497ae115bc7Smrj {
498843e1988Sjohnlev 	panic("unimplemented at line %d of %s", __LINE__, __FILE__);
499ae115bc7Smrj }
500ae115bc7Smrj 
501ae115bc7Smrj void
502ae115bc7Smrj plat_tem_hide_prom_cursor(void)
503ae115bc7Smrj {
504843e1988Sjohnlev 	panic("unimplemented at line %d of %s", __LINE__, __FILE__);
505ae115bc7Smrj }
506ae115bc7Smrj 
507843e1988Sjohnlev /*ARGSUSED*/
508ae115bc7Smrj void
509ae115bc7Smrj plat_tem_get_prom_pos(uint32_t *row, uint32_t *col)
510ae115bc7Smrj {
511843e1988Sjohnlev 	panic("unimplemented at line %d of %s", __LINE__, __FILE__);
512ae115bc7Smrj }
513