xref: /titanic_50/usr/src/uts/i86pc/io/consplat.c (revision 48b3f8de82a5c74ddb58d2d95b0796ebcefb1fb6)
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 /*
2393a18d6dSEnrico 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 
19493a18d6dSEnrico Perla - Sun Microsystems /*
19593a18d6dSEnrico Perla - Sun Microsystems  * NOTE: this function is duplicated here and in gfx_private/vgatext while
19693a18d6dSEnrico Perla - Sun Microsystems  *       we work on a set of commitable interfaces to sunpci.c.
19793a18d6dSEnrico Perla - Sun Microsystems  *
19893a18d6dSEnrico Perla - Sun Microsystems  * Use the class code to determine if the device is a PCI-to-PCI bridge.
19993a18d6dSEnrico Perla - Sun Microsystems  * Returns:  B_TRUE  if the device is a bridge.
20093a18d6dSEnrico Perla - Sun Microsystems  *           B_FALSE if the device is not a bridge or the property cannot be
20193a18d6dSEnrico Perla - Sun Microsystems  *		     retrieved.
20293a18d6dSEnrico Perla - Sun Microsystems  */
20393a18d6dSEnrico Perla - Sun Microsystems static boolean_t
20493a18d6dSEnrico Perla - Sun Microsystems is_pci_bridge(dev_info_t *dip)
20593a18d6dSEnrico Perla - Sun Microsystems {
20693a18d6dSEnrico Perla - Sun Microsystems 	uint32_t class_code;
20793a18d6dSEnrico Perla - Sun Microsystems 
20893a18d6dSEnrico Perla - Sun Microsystems 	class_code = (uint32_t)ddi_prop_get_int(DDI_DEV_T_ANY, dip,
20993a18d6dSEnrico Perla - Sun Microsystems 	    DDI_PROP_DONTPASS, "class-code", 0xffffffff);
21093a18d6dSEnrico Perla - Sun Microsystems 
21193a18d6dSEnrico Perla - Sun Microsystems 	if (class_code == 0xffffffff || class_code == DDI_PROP_NOT_FOUND)
21293a18d6dSEnrico Perla - Sun Microsystems 		return (B_FALSE);
21393a18d6dSEnrico Perla - Sun Microsystems 
21493a18d6dSEnrico Perla - Sun Microsystems 	class_code &= 0x00ffff00;
21593a18d6dSEnrico Perla - Sun Microsystems 	if (class_code == ((PCI_CLASS_BRIDGE << 16) | (PCI_BRIDGE_PCI << 8)))
21693a18d6dSEnrico Perla - Sun Microsystems 		return (B_TRUE);
21793a18d6dSEnrico Perla - Sun Microsystems 
21893a18d6dSEnrico Perla - Sun Microsystems 	return (B_FALSE);
21993a18d6dSEnrico Perla - Sun Microsystems }
22093a18d6dSEnrico Perla - Sun Microsystems 
221*48b3f8deSEdward Shu /*
222*48b3f8deSEdward Shu  * Type for the parameter of find_fb_dev()
223*48b3f8deSEdward Shu  */
224*48b3f8deSEdward Shu struct find_fb_dev_param
22545e46d06Srui zang - Sun Microsystems - Beijing China {
226*48b3f8deSEdward Shu 	dev_info_t *found_dip;	/* dip found for VGA console */
227*48b3f8deSEdward Shu 	int vga_enable;		/* check PCI_BCNF_BCNTRL_VGA_ENABLE or not */
228*48b3f8deSEdward Shu };
229*48b3f8deSEdward Shu 
230*48b3f8deSEdward Shu /*
231*48b3f8deSEdward Shu  * The VGA device could be under a subtractive PCI bridge on some systems.
232*48b3f8deSEdward Shu  * Though the PCI_BCNF_BCNTRL_VGA_ENABLE bit is not set on such subtractive
233*48b3f8deSEdward Shu  * PCI bridge, the subtractive PCI bridge can forward VGA access if no other
234*48b3f8deSEdward Shu  * agent claims the access.
235*48b3f8deSEdward Shu  * The vga_enable element in param acts as a flag, if not set, ignore the
236*48b3f8deSEdward Shu  * checking for the PCI_BCNF_BCNTRL_VGA_ENABLE bit of the PCI bridge during
237*48b3f8deSEdward Shu  * the search.
238*48b3f8deSEdward Shu  */
239*48b3f8deSEdward Shu static int
240*48b3f8deSEdward Shu find_fb_dev(dev_info_t *dip, void *param)
241*48b3f8deSEdward Shu {
242*48b3f8deSEdward Shu 	struct find_fb_dev_param *p = param;
24345e46d06Srui zang - Sun Microsystems - Beijing China 	char *dev_type;
24445e46d06Srui zang - Sun Microsystems - Beijing China 	dev_info_t *pdip;
24545e46d06Srui zang - Sun Microsystems - Beijing China 	char *parent_type;
24645e46d06Srui zang - Sun Microsystems - Beijing China 
24745e46d06Srui zang - Sun Microsystems - Beijing China 	if (dip == ddi_root_node())
24845e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_CONTINUE);
24945e46d06Srui zang - Sun Microsystems - Beijing China 
25045e46d06Srui zang - Sun Microsystems - Beijing China 	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
25145e46d06Srui zang - Sun Microsystems - Beijing China 	    "device_type", &dev_type) != DDI_SUCCESS)
25245e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
25345e46d06Srui zang - Sun Microsystems - Beijing China 
25445e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(dev_type, "isa") == 0) || (strcmp(dev_type, "eisa") == 0)) {
25545e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(dev_type);
25645e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_CONTINUE);
25745e46d06Srui zang - Sun Microsystems - Beijing China 	}
25845e46d06Srui zang - Sun Microsystems - Beijing China 
25945e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(dev_type, "pci") == 0) ||
26045e46d06Srui zang - Sun Microsystems - Beijing China 	    (strcmp(dev_type, "pciex") == 0)) {
26145e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_acc_handle_t pci_conf;
26245e46d06Srui zang - Sun Microsystems - Beijing China 		uint16_t data16;
263c401c7a8Srui zang - Sun Microsystems - Beijing China 		char *nodename;
26445e46d06Srui zang - Sun Microsystems - Beijing China 
26545e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(dev_type);
26645e46d06Srui zang - Sun Microsystems - Beijing China 
267*48b3f8deSEdward Shu 		if (!p->vga_enable)
268*48b3f8deSEdward Shu 			return (DDI_WALK_CONTINUE);
269*48b3f8deSEdward Shu 
270c401c7a8Srui zang - Sun Microsystems - Beijing China 		nodename = ddi_node_name(dip);
27145e46d06Srui zang - Sun Microsystems - Beijing China 
27293a18d6dSEnrico Perla - Sun Microsystems 		/*
27393a18d6dSEnrico Perla - Sun Microsystems 		 * If the node is not a PCI-to-PCI bridge, continue traversing
27493a18d6dSEnrico Perla - Sun Microsystems 		 * (it could be the root node), otherwise, check for the
27593a18d6dSEnrico Perla - Sun Microsystems 		 * VGAEnable bit to be set in the Bridge Control Register.
27693a18d6dSEnrico Perla - Sun Microsystems 		 */
277c401c7a8Srui zang - Sun Microsystems - Beijing China 		if (strcmp(nodename, "pci") == 0) {
27893a18d6dSEnrico Perla - Sun Microsystems 			if (is_pci_bridge(dip) == B_FALSE)
27945e46d06Srui zang - Sun Microsystems - Beijing China 				return (DDI_WALK_CONTINUE);
28045e46d06Srui zang - Sun Microsystems - Beijing China 		}
28145e46d06Srui zang - Sun Microsystems - Beijing China 
282c401c7a8Srui zang - Sun Microsystems - Beijing China 		if (i_ddi_attach_node_hierarchy(dip) != DDI_SUCCESS)
283c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
284c401c7a8Srui zang - Sun Microsystems - Beijing China 
285c401c7a8Srui zang - Sun Microsystems - Beijing China 		if (pci_config_setup(dip, &pci_conf) != DDI_SUCCESS)
286c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
287c401c7a8Srui zang - Sun Microsystems - Beijing China 
28845e46d06Srui zang - Sun Microsystems - Beijing China 		data16 = pci_config_get16(pci_conf, PCI_BCNF_BCNTRL);
28945e46d06Srui zang - Sun Microsystems - Beijing China 		pci_config_teardown(&pci_conf);
29045e46d06Srui zang - Sun Microsystems - Beijing China 
29145e46d06Srui zang - Sun Microsystems - Beijing China 		if (data16 & PCI_BCNF_BCNTRL_VGA_ENABLE)
29245e46d06Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_CONTINUE);
29345e46d06Srui zang - Sun Microsystems - Beijing China 
29445e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
29545e46d06Srui zang - Sun Microsystems - Beijing China 	}
29645e46d06Srui zang - Sun Microsystems - Beijing China 
29745e46d06Srui zang - Sun Microsystems - Beijing China 	if (strcmp(dev_type, "display") != 0) {
29845e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(dev_type);
29945e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_CONTINUE);
30045e46d06Srui zang - Sun Microsystems - Beijing China 	}
30145e46d06Srui zang - Sun Microsystems - Beijing China 
30245e46d06Srui zang - Sun Microsystems - Beijing China 	ddi_prop_free(dev_type);
30345e46d06Srui zang - Sun Microsystems - Beijing China 
30445e46d06Srui zang - Sun Microsystems - Beijing China 	if ((pdip = ddi_get_parent(dip)) == NULL)
305c401c7a8Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
30645e46d06Srui zang - Sun Microsystems - Beijing China 
30745e46d06Srui zang - Sun Microsystems - Beijing China 	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, pdip, DDI_PROP_DONTPASS,
30845e46d06Srui zang - Sun Microsystems - Beijing China 	    "device_type", &parent_type) != DDI_SUCCESS)
309c401c7a8Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_PRUNECHILD);
31045e46d06Srui zang - Sun Microsystems - Beijing China 
31145e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(parent_type, "isa") == 0) ||
31245e46d06Srui zang - Sun Microsystems - Beijing China 	    (strcmp(parent_type, "eisa") == 0)) {
313*48b3f8deSEdward Shu 		p->found_dip = dip;
31445e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(parent_type);
31545e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_TERMINATE);
31645e46d06Srui zang - Sun Microsystems - Beijing China 	}
31745e46d06Srui zang - Sun Microsystems - Beijing China 
31845e46d06Srui zang - Sun Microsystems - Beijing China 	if ((strcmp(parent_type, "pci") == 0) ||
31945e46d06Srui zang - Sun Microsystems - Beijing China 	    (strcmp(parent_type, "pciex") == 0)) {
32045e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_acc_handle_t pci_conf;
32145e46d06Srui zang - Sun Microsystems - Beijing China 		uint16_t data16;
32245e46d06Srui zang - Sun Microsystems - Beijing China 
32345e46d06Srui zang - Sun Microsystems - Beijing China 		ddi_prop_free(parent_type);
32445e46d06Srui zang - Sun Microsystems - Beijing China 
32545e46d06Srui zang - Sun Microsystems - Beijing China 		if (i_ddi_attach_node_hierarchy(dip) != DDI_SUCCESS)
326c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
32745e46d06Srui zang - Sun Microsystems - Beijing China 
32845e46d06Srui zang - Sun Microsystems - Beijing China 		if (pci_config_setup(dip, &pci_conf) != DDI_SUCCESS)
329c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
33045e46d06Srui zang - Sun Microsystems - Beijing China 
33145e46d06Srui zang - Sun Microsystems - Beijing China 		data16 = pci_config_get16(pci_conf, PCI_CONF_COMM);
33245e46d06Srui zang - Sun Microsystems - Beijing China 		pci_config_teardown(&pci_conf);
33345e46d06Srui zang - Sun Microsystems - Beijing China 
33445e46d06Srui zang - Sun Microsystems - Beijing China 		if (!(data16 & PCI_COMM_IO))
335c401c7a8Srui zang - Sun Microsystems - Beijing China 			return (DDI_WALK_PRUNECHILD);
33645e46d06Srui zang - Sun Microsystems - Beijing China 
337*48b3f8deSEdward Shu 		p->found_dip = dip;
33845e46d06Srui zang - Sun Microsystems - Beijing China 		return (DDI_WALK_TERMINATE);
33945e46d06Srui zang - Sun Microsystems - Beijing China 	}
34045e46d06Srui zang - Sun Microsystems - Beijing China 
34145e46d06Srui zang - Sun Microsystems - Beijing China 	ddi_prop_free(parent_type);
342c401c7a8Srui zang - Sun Microsystems - Beijing China 	return (DDI_WALK_PRUNECHILD);
34345e46d06Srui zang - Sun Microsystems - Beijing China }
34445e46d06Srui zang - Sun Microsystems - Beijing China 
345ae115bc7Smrj /*
346*48b3f8deSEdward Shu  * The first round search is to find:
34745e46d06Srui zang - Sun Microsystems - Beijing China  * 1) a VGA device.
34845e46d06Srui zang - Sun Microsystems - Beijing China  * 2) a PCI VGA compatible device whose IO space is enabled
34945e46d06Srui zang - Sun Microsystems - Beijing China  *    and the VGA Enable bit of any PCI-PCI bridge above it is set.
350*48b3f8deSEdward Shu  * If the first round search succeeds, prune the second round search.
351*48b3f8deSEdward Shu  *
352*48b3f8deSEdward Shu  * The second round seach does not check the VGA Enable bit.
35345e46d06Srui zang - Sun Microsystems - Beijing China  *
35445e46d06Srui zang - Sun Microsystems - Beijing China  * Return the device path as the console fb path.
355ae115bc7Smrj  */
356ae115bc7Smrj char *
357ae115bc7Smrj plat_fbpath(void)
358ae115bc7Smrj {
359*48b3f8deSEdward Shu 	struct find_fb_dev_param param;
360ae115bc7Smrj 	static char *fbpath = NULL;
361ae115bc7Smrj 	static char fbpath_buf[MAXPATHLEN];
362ae115bc7Smrj 
363*48b3f8deSEdward Shu 	/* first round search */
364*48b3f8deSEdward Shu 	param.found_dip = NULL;
365*48b3f8deSEdward Shu 	param.vga_enable = 1;
366*48b3f8deSEdward Shu 	ddi_walk_devs(ddi_root_node(), find_fb_dev, &param);
367843e1988Sjohnlev 
368*48b3f8deSEdward Shu 	if (param.found_dip != NULL) {
369*48b3f8deSEdward Shu 		(void) ddi_pathname(param.found_dip, fbpath_buf);
370*48b3f8deSEdward Shu 		fbpath = fbpath_buf;
371*48b3f8deSEdward Shu 		return (fbpath);
372*48b3f8deSEdward Shu 	}
373*48b3f8deSEdward Shu 
374*48b3f8deSEdward Shu 	/*
375*48b3f8deSEdward Shu 	 * second round search, do not check the
376*48b3f8deSEdward Shu 	 * PCI_BCNF_BCNTRL_VGA_ENABLE bit
377*48b3f8deSEdward Shu 	 */
378*48b3f8deSEdward Shu 	param.found_dip = NULL;
379*48b3f8deSEdward Shu 	param.vga_enable = 0;
380*48b3f8deSEdward Shu 	ddi_walk_devs(ddi_root_node(), find_fb_dev, &param);
381*48b3f8deSEdward Shu 
382*48b3f8deSEdward Shu 	if (param.found_dip == NULL)
38345e46d06Srui zang - Sun Microsystems - Beijing China 		return (NULL);
384843e1988Sjohnlev 
385*48b3f8deSEdward Shu 	(void) ddi_pathname(param.found_dip, fbpath_buf);
386ae115bc7Smrj 	fbpath = fbpath_buf;
387843e1988Sjohnlev 	return (fbpath);
388ae115bc7Smrj }
389ae115bc7Smrj 
390ae115bc7Smrj char *
391ae115bc7Smrj plat_mousepath(void)
392ae115bc7Smrj {
39378323854SJudy Chen 	static char mpath[MAXPATHLEN];
39478323854SJudy Chen 
395ae115bc7Smrj 	/*
396ae115bc7Smrj 	 * Hardcode to isa mouse path
397ae115bc7Smrj 	 * XXX make it settable via bootprop?
398ae115bc7Smrj 	 */
39978323854SJudy Chen 	if (pseudo_isa)
400ae115bc7Smrj 		return ("/isa/i8042@1,60/mouse@1");
40178323854SJudy Chen 
40278323854SJudy Chen 	if (plat_devpath("mouse8042", mpath) == NULL)
40378323854SJudy Chen 		return (NULL);
40478323854SJudy Chen 
40578323854SJudy Chen 	return (mpath);
406ae115bc7Smrj }
407ae115bc7Smrj 
408ae115bc7Smrj /* return path of first usb serial device */
409ae115bc7Smrj static char *
410ae115bc7Smrj plat_usbser_path(void)
411ae115bc7Smrj {
412ae115bc7Smrj 	extern dev_info_t *usbser_first_device(void);
413ae115bc7Smrj 
414ae115bc7Smrj 	dev_info_t *us_dip;
415ae115bc7Smrj 	static char *us_path = NULL;
416ae115bc7Smrj 
417ae115bc7Smrj 	if (us_path)
418ae115bc7Smrj 		return (us_path);
419ae115bc7Smrj 
420ae115bc7Smrj 	us_dip = usbser_first_device();
421ae115bc7Smrj 	if (us_dip == NULL)
422ae115bc7Smrj 		return (NULL);
423ae115bc7Smrj 
424ae115bc7Smrj 	us_path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
425ae115bc7Smrj 	(void) ddi_pathname(us_dip, us_path);
426ae115bc7Smrj 	ndi_rele_devi(us_dip);	/* held from usbser_first_device */
427ae115bc7Smrj 	return (us_path);
428ae115bc7Smrj }
429ae115bc7Smrj 
43078323854SJudy Chen static char *
43178323854SJudy Chen plat_ttypath(int inum)
43278323854SJudy Chen {
43378323854SJudy Chen 	static char *defaultpath[] = {
43478323854SJudy Chen 	    "/isa/asy@1,3f8:a",
43578323854SJudy Chen 	    "/isa/asy@1,2f8:b"
43678323854SJudy Chen 	};
43778323854SJudy Chen 	static char path[MAXPATHLEN];
43878323854SJudy Chen 	char *bp;
43978323854SJudy Chen 	major_t major;
44078323854SJudy Chen 	dev_info_t *dip;
44178323854SJudy Chen 
44278323854SJudy Chen 	if (pseudo_isa)
44378323854SJudy Chen 		return (defaultpath[inum]);
44478323854SJudy Chen 
44578323854SJudy Chen 	if ((major = ddi_name_to_major("asy")) == (major_t)-1)
44678323854SJudy Chen 		return (NULL);
44778323854SJudy Chen 
44878323854SJudy Chen 	if ((dip = devnamesp[major].dn_head) == NULL)
44978323854SJudy Chen 		return (NULL);
45078323854SJudy Chen 
45101457ffdSJudy Chen 	for (; dip != NULL; dip = ddi_get_next(dip)) {
45278323854SJudy Chen 		if (i_ddi_attach_node_hierarchy(dip) != DDI_SUCCESS)
45378323854SJudy Chen 			return (NULL);
45478323854SJudy Chen 
45501457ffdSJudy Chen 		if (DEVI(dip)->devi_minor->ddm_name[0] == ('a' + (char)inum))
45601457ffdSJudy Chen 			break;
45701457ffdSJudy Chen 	}
45801457ffdSJudy Chen 	if (dip == NULL)
45901457ffdSJudy Chen 		return (NULL);
46001457ffdSJudy Chen 
46178323854SJudy Chen 	(void) ddi_pathname(dip, path);
46278323854SJudy Chen 	bp = path + strlen(path);
46378323854SJudy Chen 	(void) snprintf(bp, 3, ":%s", DEVI(dip)->devi_minor->ddm_name);
46478323854SJudy Chen 
46578323854SJudy Chen 	return (path);
46678323854SJudy Chen }
46778323854SJudy Chen 
468ae115bc7Smrj /*
469ae115bc7Smrj  * Lacking support for com2 and com3, if that matters.
470ae115bc7Smrj  * Another possible enhancement could be to use properties
471ae115bc7Smrj  * for the port mapping rather than simply hard-code them.
472ae115bc7Smrj  */
473ae115bc7Smrj char *
474ae115bc7Smrj plat_stdinpath(void)
475ae115bc7Smrj {
476ae115bc7Smrj 	switch (console_type()) {
477843e1988Sjohnlev #if defined(__xpv)
478843e1988Sjohnlev 	case CONS_HYPERVISOR:
479843e1988Sjohnlev 		return ("/xpvd/xencons@0");
480843e1988Sjohnlev #endif /* __xpv */
481ae115bc7Smrj 	case CONS_TTYA:
48278323854SJudy Chen 		return (plat_ttypath(0));
483ae115bc7Smrj 	case CONS_TTYB:
48478323854SJudy Chen 		return (plat_ttypath(1));
485ae115bc7Smrj 	case CONS_USBSER:
486ae115bc7Smrj 		return (plat_usbser_path());
487ae115bc7Smrj 	case CONS_SCREEN:
488ae115bc7Smrj 	default:
489ae115bc7Smrj 		break;
490ae115bc7Smrj 	};
491ae115bc7Smrj 	return (plat_kbdpath());
492ae115bc7Smrj }
493ae115bc7Smrj 
494ae115bc7Smrj char *
495ae115bc7Smrj plat_stdoutpath(void)
496ae115bc7Smrj {
497ae115bc7Smrj 	switch (console_type()) {
498843e1988Sjohnlev #if defined(__xpv)
499843e1988Sjohnlev 	case CONS_HYPERVISOR:
500843e1988Sjohnlev 		return ("/xpvd/xencons@0");
501843e1988Sjohnlev #endif /* __xpv */
502ae115bc7Smrj 	case CONS_TTYA:
50378323854SJudy Chen 		return (plat_ttypath(0));
504ae115bc7Smrj 	case CONS_TTYB:
50578323854SJudy Chen 		return (plat_ttypath(1));
506ae115bc7Smrj 	case CONS_USBSER:
507ae115bc7Smrj 		return (plat_usbser_path());
508ae115bc7Smrj 	case CONS_SCREEN:
509ae115bc7Smrj 	default:
510ae115bc7Smrj 		break;
511ae115bc7Smrj 	};
512ae115bc7Smrj 	return (plat_fbpath());
513ae115bc7Smrj }
514ae115bc7Smrj 
515ae115bc7Smrj /*
516ae115bc7Smrj  * If VIS_PIXEL mode will be implemented on x86, these following
517ae115bc7Smrj  * functions should be re-considered. Now these functions are
518ae115bc7Smrj  * unused on x86.
519ae115bc7Smrj  */
520ae115bc7Smrj void
521c9503a49Slq150181 plat_tem_get_inverses(int *inverse, int *inverse_screen)
522c9503a49Slq150181 {
523c9503a49Slq150181 	*inverse = 0;
524c9503a49Slq150181 	*inverse_screen = 0;
525c9503a49Slq150181 }
526c9503a49Slq150181 
527c9503a49Slq150181 void
528ae115bc7Smrj plat_tem_get_prom_font_size(int *charheight, int *windowtop)
529ae115bc7Smrj {
530ae115bc7Smrj 	*charheight = 0;
531ae115bc7Smrj 	*windowtop = 0;
532ae115bc7Smrj }
533ae115bc7Smrj 
534843e1988Sjohnlev /*ARGSUSED*/
535ae115bc7Smrj void
536ae115bc7Smrj plat_tem_get_prom_size(size_t *height, size_t *width)
537ae115bc7Smrj {
538843e1988Sjohnlev 	panic("unimplemented at line %d of %s", __LINE__, __FILE__);
539ae115bc7Smrj }
540ae115bc7Smrj 
541ae115bc7Smrj void
542ae115bc7Smrj plat_tem_hide_prom_cursor(void)
543ae115bc7Smrj {
544843e1988Sjohnlev 	panic("unimplemented at line %d of %s", __LINE__, __FILE__);
545ae115bc7Smrj }
546ae115bc7Smrj 
547843e1988Sjohnlev /*ARGSUSED*/
548ae115bc7Smrj void
549ae115bc7Smrj plat_tem_get_prom_pos(uint32_t *row, uint32_t *col)
550ae115bc7Smrj {
551843e1988Sjohnlev 	panic("unimplemented at line %d of %s", __LINE__, __FILE__);
552ae115bc7Smrj }
553