17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2294ee2d0fSJimmy Vetayases  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
24629c07fbSJohn Levon  * Copyright 2018 Joyent, Inc.  All rights reserved.
25*aa39f6d0SPatrick Mooney  * Copyright 2022 Oxide Computer Company
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include <regex.h>
297c478bd9Sstevel@tonic-gate #include <devfsadm.h>
307c478bd9Sstevel@tonic-gate #include <stdio.h>
317c478bd9Sstevel@tonic-gate #include <strings.h>
327c478bd9Sstevel@tonic-gate #include <stdlib.h>
337c478bd9Sstevel@tonic-gate #include <limits.h>
347c478bd9Sstevel@tonic-gate #include <ctype.h>
3520c794b3Sgavinm #include <sys/mc_amd.h>
3645916cd2Sjpk #include <bsm/devalloc.h>
3745916cd2Sjpk 
3845916cd2Sjpk extern int system_labeled;
397c478bd9Sstevel@tonic-gate 
40629c07fbSJohn Levon static int ln_minor_name(di_minor_t minor, di_node_t node);
417c478bd9Sstevel@tonic-gate static int lp(di_minor_t minor, di_node_t node);
427c478bd9Sstevel@tonic-gate static int serial_dialout(di_minor_t minor, di_node_t node);
437c478bd9Sstevel@tonic-gate static int serial(di_minor_t minor, di_node_t node);
447c478bd9Sstevel@tonic-gate static int diskette(di_minor_t minor, di_node_t node);
457c478bd9Sstevel@tonic-gate static int vt00(di_minor_t minor, di_node_t node);
467c478bd9Sstevel@tonic-gate static int kdmouse(di_minor_t minor, di_node_t node);
47989f2807SJerry Jelinek static int ipmi(di_minor_t minor, di_node_t node);
487aec1d6eScindi static int mc_node(di_minor_t minor, di_node_t node);
494c87aefeSPatrick Mooney static int vmmctl(di_minor_t minor, di_node_t node);
50eb9a1df2SHans Rosenfeld static int ppt(di_minor_t minor, di_node_t node);
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate static devfsadm_create_t misc_cbt[] = {
537c478bd9Sstevel@tonic-gate 	{ "vt00", "ddi_display", NULL,
547c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_0,	vt00
557c478bd9Sstevel@tonic-gate 	},
567c478bd9Sstevel@tonic-gate 	{ "mouse", "ddi_mouse", "mouse8042",
577c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, kdmouse
587c478bd9Sstevel@tonic-gate 	},
59989f2807SJerry Jelinek 	{ "pseudo", "ddi_pseudo", "ipmi",
60989f2807SJerry Jelinek 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, ipmi,
617c478bd9Sstevel@tonic-gate 	},
6284ab085aSmws 	{ "pseudo", "ddi_pseudo", "smbios",
63629c07fbSJohn Levon 	    TYPE_EXACT | DRV_EXACT, ILEVEL_1, ln_minor_name,
6484ab085aSmws 	},
6594ee2d0fSJimmy Vetayases 	/* floppies share the same class, but not link regex, as hard disks */
667c478bd9Sstevel@tonic-gate 	{ "disk",  "ddi_block:diskette", NULL,
677c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_1, diskette
687c478bd9Sstevel@tonic-gate 	},
697c478bd9Sstevel@tonic-gate 	{ "parallel",  "ddi_printer", NULL,
707c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_1, lp
717c478bd9Sstevel@tonic-gate 	},
727c478bd9Sstevel@tonic-gate 	{ "serial", "ddi_serial:mb", NULL,
737c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_1, serial
747c478bd9Sstevel@tonic-gate 	},
757c478bd9Sstevel@tonic-gate 	{ "serial",  "ddi_serial:dialout,mb", NULL,
767c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_1, serial_dialout
777c478bd9Sstevel@tonic-gate 	},
78629c07fbSJohn Levon 	{ "pseudo", "ddi_pseudo", "xsvc",
79629c07fbSJohn Levon 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, ln_minor_name,
80ae115bc7Smrj 	},
81629c07fbSJohn Levon 	{ "pseudo", "ddi_pseudo", "srn",
82629c07fbSJohn Levon 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, ln_minor_name,
832df1fe9cSrandyf 	},
847aec1d6eScindi 	{ "memory-controller", "ddi_mem_ctrl", NULL,
857aec1d6eScindi 	    TYPE_EXACT, ILEVEL_0, mc_node
862449e17fSsherrym 	},
872449e17fSsherrym 	{ "pseudo", "ddi_pseudo", "ucode",
88629c07fbSJohn Levon 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, ln_minor_name,
89617e2443SMark Logan 	},
90b22a70abSPatrick Mooney 	{ "pseudo", "ddi_pseudo", "viona",
91b22a70abSPatrick Mooney 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, ln_minor_name,
92b22a70abSPatrick Mooney 	},
934c87aefeSPatrick Mooney 	{ "pseudo", "ddi_pseudo", "vmm",
944c87aefeSPatrick Mooney 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, vmmctl,
95eb9a1df2SHans Rosenfeld 	},
96eb9a1df2SHans Rosenfeld 	{ "pseudo", "ddi_pseudo", "ppt",
97eb9a1df2SHans Rosenfeld 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, ppt,
98*aa39f6d0SPatrick Mooney 	},
99*aa39f6d0SPatrick Mooney 	{ "pseudo", "ddi_pseudo", "vmm_drv_test",
100*aa39f6d0SPatrick Mooney 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, ln_minor_name,
1014c87aefeSPatrick Mooney 	}
1027c478bd9Sstevel@tonic-gate };
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate DEVFSADM_CREATE_INIT_V0(misc_cbt);
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate static devfsadm_remove_t misc_remove_cbt[] = {
1077c478bd9Sstevel@tonic-gate 	{ "vt", "vt[0-9][0-9]", RM_PRE|RM_ALWAYS,
1087c478bd9Sstevel@tonic-gate 		ILEVEL_0, devfsadm_rm_all
1092449e17fSsherrym 	},
1102449e17fSsherrym 	{ "pseudo", "^ucode$", RM_ALWAYS | RM_PRE | RM_HOT,
1112449e17fSsherrym 		ILEVEL_0, devfsadm_rm_all
11294ee2d0fSJimmy Vetayases 	},
11394ee2d0fSJimmy Vetayases 	{ "mouse", "^kdmouse$", RM_ALWAYS | RM_PRE,
11494ee2d0fSJimmy Vetayases 		ILEVEL_0, devfsadm_rm_all
11594ee2d0fSJimmy Vetayases 	},
11694ee2d0fSJimmy Vetayases 	{ "disk", "^(diskette|rdiskette)([0-9]*)$",
11794ee2d0fSJimmy Vetayases 		RM_ALWAYS | RM_PRE, ILEVEL_1, devfsadm_rm_all
11894ee2d0fSJimmy Vetayases 	},
11994ee2d0fSJimmy Vetayases 	{ "parallel", "^(lp|ecpp)([0-9]+)$", RM_ALWAYS | RM_PRE,
12094ee2d0fSJimmy Vetayases 		ILEVEL_1, devfsadm_rm_all
12194ee2d0fSJimmy Vetayases 	},
12294ee2d0fSJimmy Vetayases 	{ "serial", "^(tty|ttyd)([0-9]+)$", RM_ALWAYS | RM_PRE,
12394ee2d0fSJimmy Vetayases 		ILEVEL_1, devfsadm_rm_all
12494ee2d0fSJimmy Vetayases 	},
12594ee2d0fSJimmy Vetayases 	{ "serial", "^tty[a-z]$", RM_ALWAYS | RM_PRE,
12694ee2d0fSJimmy Vetayases 		ILEVEL_1, devfsadm_rm_all
1274c87aefeSPatrick Mooney 	},
128b22a70abSPatrick Mooney 	{ "pseudo", "^viona$", RM_ALWAYS | RM_PRE | RM_HOT,
129b22a70abSPatrick Mooney 		ILEVEL_0, devfsadm_rm_all
130b22a70abSPatrick Mooney 	},
1314c87aefeSPatrick Mooney 	{ "pseudo", "^vmmctl$", RM_ALWAYS | RM_PRE | RM_HOT,
1324c87aefeSPatrick Mooney 		ILEVEL_0, devfsadm_rm_all
133eb9a1df2SHans Rosenfeld 	},
134eb9a1df2SHans Rosenfeld 	{ "pseudo", "^ppt$", RM_ALWAYS | RM_PRE | RM_HOT,
135eb9a1df2SHans Rosenfeld 		ILEVEL_0, devfsadm_rm_all
1367c478bd9Sstevel@tonic-gate 	}
1377c478bd9Sstevel@tonic-gate };
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate DEVFSADM_REMOVE_INIT_V0(misc_remove_cbt);
1407c478bd9Sstevel@tonic-gate 
141629c07fbSJohn Levon /*
142629c07fbSJohn Levon  * Any /dev/foo entry named after the minor name such as
143629c07fbSJohn Levon  * /devices/.../driver@0:foo
144629c07fbSJohn Levon  */
145629c07fbSJohn Levon static int
ln_minor_name(di_minor_t minor,di_node_t node)146629c07fbSJohn Levon ln_minor_name(di_minor_t minor, di_node_t node)
147629c07fbSJohn Levon {
148629c07fbSJohn Levon 	(void) devfsadm_mklink(di_minor_name(minor), node, minor, 0);
149629c07fbSJohn Levon 	return (DEVFSADM_CONTINUE);
150629c07fbSJohn Levon }
151629c07fbSJohn Levon 
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate  * Handles minor node type "ddi_display", in addition to generic processing
1547c478bd9Sstevel@tonic-gate  * done by display().
1557c478bd9Sstevel@tonic-gate  *
1567c478bd9Sstevel@tonic-gate  * This creates a /dev/vt00 link to /dev/fb, for backwards compatibility.
1577c478bd9Sstevel@tonic-gate  */
1587c478bd9Sstevel@tonic-gate /* ARGSUSED */
1597c478bd9Sstevel@tonic-gate int
vt00(di_minor_t minor,di_node_t node)1607c478bd9Sstevel@tonic-gate vt00(di_minor_t minor, di_node_t node)
1617c478bd9Sstevel@tonic-gate {
1627c478bd9Sstevel@tonic-gate 	(void) devfsadm_secondary_link("vt00", "fb", 0);
1637c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate /*
1677c478bd9Sstevel@tonic-gate  * type=ddi_block:diskette;addr=0,0;minor=c        diskette
1687c478bd9Sstevel@tonic-gate  * type=ddi_block:diskette;addr=0,0;minor=c,raw    rdiskette
1697c478bd9Sstevel@tonic-gate  * type=ddi_block:diskette;addr1=0;minor=c diskette\A2
1707c478bd9Sstevel@tonic-gate  * type=ddi_block:diskette;addr1=0;minor=c,raw     rdiskette\A2
1717c478bd9Sstevel@tonic-gate  */
1727c478bd9Sstevel@tonic-gate static int
diskette(di_minor_t minor,di_node_t node)1737c478bd9Sstevel@tonic-gate diskette(di_minor_t minor, di_node_t node)
1747c478bd9Sstevel@tonic-gate {
17545916cd2Sjpk 	int flags = 0;
1767c478bd9Sstevel@tonic-gate 	char *a2;
1777c478bd9Sstevel@tonic-gate 	char link[PATH_MAX];
1787c478bd9Sstevel@tonic-gate 	char *addr = di_bus_addr(node);
1797c478bd9Sstevel@tonic-gate 	char *mn = di_minor_name(minor);
1807c478bd9Sstevel@tonic-gate 
18145916cd2Sjpk 	if (system_labeled)
18245916cd2Sjpk 		flags = DA_ADD|DA_FLOPPY;
18345916cd2Sjpk 
1847c478bd9Sstevel@tonic-gate 	if (strcmp(addr, "0,0") == 0) {
1857c478bd9Sstevel@tonic-gate 		if (strcmp(mn, "c") == 0) {
18645916cd2Sjpk 			(void) devfsadm_mklink("diskette", node, minor, flags);
1877c478bd9Sstevel@tonic-gate 		} else if (strcmp(mn, "c,raw") == 0) {
18845916cd2Sjpk 			(void) devfsadm_mklink("rdiskette", node, minor, flags);
1897c478bd9Sstevel@tonic-gate 		}
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate 	}
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 	if (addr[0] == '0') {
1947c478bd9Sstevel@tonic-gate 		if ((a2 = strchr(addr, ',')) != NULL) {
1957c478bd9Sstevel@tonic-gate 			a2++;
1967c478bd9Sstevel@tonic-gate 			if (strcmp(mn, "c") == 0) {
1977c478bd9Sstevel@tonic-gate 				(void) strcpy(link, "diskette");
1987c478bd9Sstevel@tonic-gate 				(void) strcat(link, a2);
19945916cd2Sjpk 				(void) devfsadm_mklink(link, node, minor,
20045916cd2Sjpk 				    flags);
2017c478bd9Sstevel@tonic-gate 			} else if (strcmp(mn, "c,raw") == 0) {
2027c478bd9Sstevel@tonic-gate 				(void) strcpy(link, "rdiskette");
2037c478bd9Sstevel@tonic-gate 				(void) strcat(link, a2);
20445916cd2Sjpk 				(void) devfsadm_mklink(link, node, minor,
20545916cd2Sjpk 				    flags);
2067c478bd9Sstevel@tonic-gate 			}
2077c478bd9Sstevel@tonic-gate 		}
2087c478bd9Sstevel@tonic-gate 	}
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
2117c478bd9Sstevel@tonic-gate }
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate /*
2147c478bd9Sstevel@tonic-gate  * type=ddi_printer;name=lp;addr=1,3bc      lp0
2157c478bd9Sstevel@tonic-gate  * type=ddi_printer;name=lp;addr=1,378      lp1
2167c478bd9Sstevel@tonic-gate  * type=ddi_printer;name=lp;addr=1,278      lp2
2177c478bd9Sstevel@tonic-gate  */
2187c478bd9Sstevel@tonic-gate static int
lp(di_minor_t minor,di_node_t node)2197c478bd9Sstevel@tonic-gate lp(di_minor_t minor, di_node_t node)
2207c478bd9Sstevel@tonic-gate {
2217c478bd9Sstevel@tonic-gate 	char *addr = di_bus_addr(node);
2227c478bd9Sstevel@tonic-gate 	char *buf;
2237c478bd9Sstevel@tonic-gate 	char path[PATH_MAX + 1];
2247c478bd9Sstevel@tonic-gate 	devfsadm_enumerate_t rules[1] = {"^ecpp([0-9]+)$", 1, MATCH_ALL};
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate 	if (strcmp(addr, "1,3bc") == 0) {
2277c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("lp0", node, minor, 0);
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate 	} else if (strcmp(addr, "1,378") == 0) {
2307c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("lp1", node, minor, 0);
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate 	} else if (strcmp(addr, "1,278") == 0) {
2337c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("lp2", node, minor, 0);
2347c478bd9Sstevel@tonic-gate 	}
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate 	if (strcmp(di_driver_name(node), "ecpp") != 0) {
2377c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
2387c478bd9Sstevel@tonic-gate 	}
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate 	if ((buf = di_devfs_path(node)) == NULL) {
2417c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
2427c478bd9Sstevel@tonic-gate 	}
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate 	(void) snprintf(path, sizeof (path), "%s:%s",
2457c478bd9Sstevel@tonic-gate 	    buf, di_minor_name(minor));
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate 	di_devfs_path_free(buf);
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate 	if (devfsadm_enumerate_int(path, 0, &buf, rules, 1)) {
2507c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
2517c478bd9Sstevel@tonic-gate 	}
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate 	(void) snprintf(path, sizeof (path), "ecpp%s", buf);
2547c478bd9Sstevel@tonic-gate 	free(buf);
2557c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(path, node, minor, 0);
2567c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
2577c478bd9Sstevel@tonic-gate }
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate /*
2607c478bd9Sstevel@tonic-gate  * type=ddi_serial:mb;minor=a      tty00
2617c478bd9Sstevel@tonic-gate  * type=ddi_serial:mb;minor=b      tty01
2627c478bd9Sstevel@tonic-gate  * type=ddi_serial:mb;minor=c      tty02
2637c478bd9Sstevel@tonic-gate  * type=ddi_serial:mb;minor=d      tty03
2647c478bd9Sstevel@tonic-gate  */
2657c478bd9Sstevel@tonic-gate static int
serial(di_minor_t minor,di_node_t node)2667c478bd9Sstevel@tonic-gate serial(di_minor_t minor, di_node_t node)
2677c478bd9Sstevel@tonic-gate {
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate 	char *mn = di_minor_name(minor);
2707c478bd9Sstevel@tonic-gate 	char link[PATH_MAX];
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate 	(void) strcpy(link, "tty");
2737c478bd9Sstevel@tonic-gate 	(void) strcat(link, mn);
2747c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(link, node, minor, 0);
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate 	if (strcmp(mn, "a") == 0) {
2777c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("tty00", node, minor, 0);
2787c478bd9Sstevel@tonic-gate 
2797c478bd9Sstevel@tonic-gate 	} else if (strcmp(mn, "b") == 0) {
2807c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("tty01", node, minor, 0);
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate 	} else if (strcmp(mn, "c") == 0) {
2837c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("tty02", node, minor, 0);
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate 	} else if (strcmp(mn, "d") == 0) {
2867c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("tty03", node, minor, 0);
2877c478bd9Sstevel@tonic-gate 	}
2887c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
2897c478bd9Sstevel@tonic-gate }
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate /*
2927c478bd9Sstevel@tonic-gate  * type=ddi_serial:dialout,mb;minor=a,cu   ttyd0
2937c478bd9Sstevel@tonic-gate  * type=ddi_serial:dialout,mb;minor=b,cu   ttyd1
2947c478bd9Sstevel@tonic-gate  * type=ddi_serial:dialout,mb;minor=c,cu   ttyd2
2957c478bd9Sstevel@tonic-gate  * type=ddi_serial:dialout,mb;minor=d,cu   ttyd3
2967c478bd9Sstevel@tonic-gate  */
2977c478bd9Sstevel@tonic-gate static int
serial_dialout(di_minor_t minor,di_node_t node)2987c478bd9Sstevel@tonic-gate serial_dialout(di_minor_t minor, di_node_t node)
2997c478bd9Sstevel@tonic-gate {
3007c478bd9Sstevel@tonic-gate 	char *mn = di_minor_name(minor);
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate 	if (strcmp(mn, "a,cu") == 0) {
3037c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("ttyd0", node, minor, 0);
3047c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("cua0", node, minor, 0);
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate 	} else if (strcmp(mn, "b,cu") == 0) {
3077c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("ttyd1", node, minor, 0);
3087c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("cua1", node, minor, 0);
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate 	} else if (strcmp(mn, "c,cu") == 0) {
3117c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("ttyd2", node, minor, 0);
3127c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("cua2", node, minor, 0);
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate 	} else if (strcmp(mn, "d,cu") == 0) {
3157c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("ttyd3", node, minor, 0);
3167c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("cua3", node, minor, 0);
3177c478bd9Sstevel@tonic-gate 	}
3187c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
3197c478bd9Sstevel@tonic-gate }
3207c478bd9Sstevel@tonic-gate 
3217c478bd9Sstevel@tonic-gate static int
kdmouse(di_minor_t minor,di_node_t node)3227c478bd9Sstevel@tonic-gate kdmouse(di_minor_t minor, di_node_t node)
3237c478bd9Sstevel@tonic-gate {
3247c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink("kdmouse", node, minor, 0);
3257c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
3267c478bd9Sstevel@tonic-gate }
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate static int
ipmi(di_minor_t minor,di_node_t node)329989f2807SJerry Jelinek ipmi(di_minor_t minor, di_node_t node)
3307c478bd9Sstevel@tonic-gate {
331989f2807SJerry Jelinek 	/*
332989f2807SJerry Jelinek 	 * Follow convention from other systems, and include an instance#,
333989f2807SJerry Jelinek 	 * even though there will only be one.
334989f2807SJerry Jelinek 	 */
335989f2807SJerry Jelinek 	(void) devfsadm_mklink("ipmi0", node, minor, 0);
3367c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
3377c478bd9Sstevel@tonic-gate }
33884ab085aSmws 
3397aec1d6eScindi /*
3407aec1d6eScindi  * /dev/mc/mc<chipid> -> /devices/.../pci1022,1102@<chipid+24>,2:mc-amd
3417aec1d6eScindi  */
3427aec1d6eScindi static int
mc_node(di_minor_t minor,di_node_t node)3437aec1d6eScindi mc_node(di_minor_t minor, di_node_t node)
3447aec1d6eScindi {
3457aec1d6eScindi 	const char *minorname = di_minor_name(minor);
3467aec1d6eScindi 	const char *busaddr = di_bus_addr(node);
3477aec1d6eScindi 	char linkpath[PATH_MAX];
3487aec1d6eScindi 	int unitaddr;
3497aec1d6eScindi 	char *c;
3507aec1d6eScindi 
3517aec1d6eScindi 	if (minorname == NULL || busaddr == NULL)
3527aec1d6eScindi 		return (DEVFSADM_CONTINUE);
3537aec1d6eScindi 
3547aec1d6eScindi 	errno = 0;
3557aec1d6eScindi 	unitaddr = strtol(busaddr, &c, 16);
3567aec1d6eScindi 
35720c794b3Sgavinm 	if (errno != 0)
3587aec1d6eScindi 		return (DEVFSADM_CONTINUE);
3597aec1d6eScindi 
36020c794b3Sgavinm 	if (unitaddr == 0) {
36120c794b3Sgavinm 		(void) snprintf(linkpath, sizeof (linkpath), "mc/mc");
36220c794b3Sgavinm 	} else if (unitaddr >= MC_AMD_DEV_OFFSET) {
36320c794b3Sgavinm 		(void) snprintf(linkpath, sizeof (linkpath), "mc/mc%u",
36420c794b3Sgavinm 		    unitaddr - MC_AMD_DEV_OFFSET);
36520c794b3Sgavinm 	} else {
366e3d60c9bSAdrian Frost 		(void) snprintf(linkpath, sizeof (linkpath), "mc/mc%u",
367e3d60c9bSAdrian Frost 		    minor->dev_minor);
36820c794b3Sgavinm 	}
3697aec1d6eScindi 	(void) devfsadm_mklink(linkpath, node, minor, 0);
3707aec1d6eScindi 	return (DEVFSADM_CONTINUE);
3717aec1d6eScindi }
3724c87aefeSPatrick Mooney 
3734c87aefeSPatrick Mooney /*
3744c87aefeSPatrick Mooney  *	/dev/vmmctl	->	/devices/pseudo/vmm@0:ctl
3754c87aefeSPatrick Mooney  */
3764c87aefeSPatrick Mooney static int
vmmctl(di_minor_t minor,di_node_t node)3774c87aefeSPatrick Mooney vmmctl(di_minor_t minor, di_node_t node)
3784c87aefeSPatrick Mooney {
3794c87aefeSPatrick Mooney 	if (strcmp(di_minor_name(minor), "ctl") == 0)
3804c87aefeSPatrick Mooney 		(void) devfsadm_mklink("vmmctl", node, minor, 0);
3814c87aefeSPatrick Mooney 	return (DEVFSADM_CONTINUE);
3824c87aefeSPatrick Mooney }
383eb9a1df2SHans Rosenfeld 
384eb9a1df2SHans Rosenfeld static int
ppt(di_minor_t minor,di_node_t node)385eb9a1df2SHans Rosenfeld ppt(di_minor_t minor, di_node_t node)
386eb9a1df2SHans Rosenfeld {
387eb9a1df2SHans Rosenfeld 	char linkpath[PATH_MAX];
388eb9a1df2SHans Rosenfeld 
389eb9a1df2SHans Rosenfeld 	(void) snprintf(linkpath, sizeof (linkpath), "ppt%d",
390eb9a1df2SHans Rosenfeld 	    di_instance(node));
391eb9a1df2SHans Rosenfeld 
392eb9a1df2SHans Rosenfeld 	(void) devfsadm_mklink(linkpath, node, minor, 0);
393eb9a1df2SHans Rosenfeld 	return (DEVFSADM_CONTINUE);
394eb9a1df2SHans Rosenfeld }
395