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 5*45916cd2Sjpk * Common Development and Distribution License (the "License"). 6*45916cd2Sjpk * 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 /* 227aec1d6eScindi * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 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> 357aec1d6eScindi #include <sys/mc.h> 36*45916cd2Sjpk #include <bsm/devalloc.h> 37*45916cd2Sjpk 38*45916cd2Sjpk extern int system_labeled; 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate static int lp(di_minor_t minor, di_node_t node); 417c478bd9Sstevel@tonic-gate static int serial_dialout(di_minor_t minor, di_node_t node); 427c478bd9Sstevel@tonic-gate static int serial(di_minor_t minor, di_node_t node); 437c478bd9Sstevel@tonic-gate static int diskette(di_minor_t minor, di_node_t node); 447c478bd9Sstevel@tonic-gate static int vt00(di_minor_t minor, di_node_t node); 457c478bd9Sstevel@tonic-gate static int kdmouse(di_minor_t minor, di_node_t node); 467c478bd9Sstevel@tonic-gate static int bmc(di_minor_t minor, di_node_t node); 4784ab085aSmws static int smbios(di_minor_t minor, di_node_t node); 487c478bd9Sstevel@tonic-gate static int agp_process(di_minor_t minor, di_node_t node); 497aec1d6eScindi static int mc_node(di_minor_t minor, di_node_t node); 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate static devfsadm_create_t misc_cbt[] = { 527c478bd9Sstevel@tonic-gate { "vt00", "ddi_display", NULL, 537c478bd9Sstevel@tonic-gate TYPE_EXACT, ILEVEL_0, vt00 547c478bd9Sstevel@tonic-gate }, 557c478bd9Sstevel@tonic-gate { "mouse", "ddi_mouse", "mouse8042", 567c478bd9Sstevel@tonic-gate TYPE_EXACT | DRV_EXACT, ILEVEL_0, kdmouse 577c478bd9Sstevel@tonic-gate }, 587c478bd9Sstevel@tonic-gate { "pseudo", "ddi_pseudo", "bmc", 597c478bd9Sstevel@tonic-gate TYPE_EXACT | DRV_EXACT, ILEVEL_0, bmc, 607c478bd9Sstevel@tonic-gate }, 6184ab085aSmws { "pseudo", "ddi_pseudo", "smbios", 6284ab085aSmws TYPE_EXACT | DRV_EXACT, ILEVEL_1, smbios, 6384ab085aSmws }, 647c478bd9Sstevel@tonic-gate { "disk", "ddi_block:diskette", NULL, 657c478bd9Sstevel@tonic-gate TYPE_EXACT, ILEVEL_1, diskette 667c478bd9Sstevel@tonic-gate }, 677c478bd9Sstevel@tonic-gate { "parallel", "ddi_printer", NULL, 687c478bd9Sstevel@tonic-gate TYPE_EXACT, ILEVEL_1, lp 697c478bd9Sstevel@tonic-gate }, 707c478bd9Sstevel@tonic-gate { "serial", "ddi_serial:mb", NULL, 717c478bd9Sstevel@tonic-gate TYPE_EXACT, ILEVEL_1, serial 727c478bd9Sstevel@tonic-gate }, 737c478bd9Sstevel@tonic-gate { "serial", "ddi_serial:dialout,mb", NULL, 747c478bd9Sstevel@tonic-gate TYPE_EXACT, ILEVEL_1, serial_dialout 757c478bd9Sstevel@tonic-gate }, 767aec1d6eScindi { "agp", "ddi_agp:pseudo", NULL, 777c478bd9Sstevel@tonic-gate TYPE_EXACT, ILEVEL_0, agp_process 787c478bd9Sstevel@tonic-gate }, 797aec1d6eScindi { "agp", "ddi_agp:target", NULL, 807c478bd9Sstevel@tonic-gate TYPE_EXACT, ILEVEL_0, agp_process 817c478bd9Sstevel@tonic-gate }, 827aec1d6eScindi { "agp", "ddi_agp:cpugart", NULL, 837c478bd9Sstevel@tonic-gate TYPE_EXACT, ILEVEL_0, agp_process 847c478bd9Sstevel@tonic-gate }, 857aec1d6eScindi { "agp", "ddi_agp:master", NULL, 867c478bd9Sstevel@tonic-gate TYPE_EXACT, ILEVEL_0, agp_process 877aec1d6eScindi }, 887aec1d6eScindi { "memory-controller", "ddi_mem_ctrl", NULL, 897aec1d6eScindi TYPE_EXACT, ILEVEL_0, mc_node 907c478bd9Sstevel@tonic-gate } 917c478bd9Sstevel@tonic-gate }; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate DEVFSADM_CREATE_INIT_V0(misc_cbt); 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate static char *debug_mid = "agp_mid"; 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate typedef enum { 987c478bd9Sstevel@tonic-gate DRIVER_AGPPSEUDO = 0, 997c478bd9Sstevel@tonic-gate DRIVER_AGPTARGET, 1007c478bd9Sstevel@tonic-gate DRIVER_CPUGART, 1017c478bd9Sstevel@tonic-gate DRIVER_AGPMASTER, 1027c478bd9Sstevel@tonic-gate DRIVER_UNKNOWN 1037c478bd9Sstevel@tonic-gate } driver_defs_t; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate typedef struct { 1067c478bd9Sstevel@tonic-gate char *driver_name; 1077c478bd9Sstevel@tonic-gate int index; 1087c478bd9Sstevel@tonic-gate } driver_name_table_entry_t; 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate static driver_name_table_entry_t driver_name_table[] = { 1117c478bd9Sstevel@tonic-gate { "agpgart", DRIVER_AGPPSEUDO }, 1127c478bd9Sstevel@tonic-gate { "agptarget", DRIVER_AGPTARGET }, 1137c478bd9Sstevel@tonic-gate { "amd64_gart", DRIVER_CPUGART }, 1147c478bd9Sstevel@tonic-gate { "vgatext", DRIVER_AGPMASTER }, 1157c478bd9Sstevel@tonic-gate { NULL, DRIVER_UNKNOWN } 1167c478bd9Sstevel@tonic-gate }; 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate static devfsadm_enumerate_t agptarget_rules[1] = 1197c478bd9Sstevel@tonic-gate { "^agp$/^agptarget([0-9]+)$", 1, MATCH_ALL }; 1207c478bd9Sstevel@tonic-gate static devfsadm_enumerate_t cpugart_rules[1] = 1217c478bd9Sstevel@tonic-gate { "^agp$/^cpugart([0-9]+)$", 1, MATCH_ALL }; 1227c478bd9Sstevel@tonic-gate static devfsadm_enumerate_t agpmaster_rules[1] = 1237c478bd9Sstevel@tonic-gate { "^agp$/^agpmaster([0-9]+)$", 1, MATCH_ALL }; 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate static devfsadm_remove_t misc_remove_cbt[] = { 1267c478bd9Sstevel@tonic-gate { "vt", "vt[0-9][0-9]", RM_PRE|RM_ALWAYS, 1277c478bd9Sstevel@tonic-gate ILEVEL_0, devfsadm_rm_all 1287c478bd9Sstevel@tonic-gate } 1297c478bd9Sstevel@tonic-gate }; 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate DEVFSADM_REMOVE_INIT_V0(misc_remove_cbt); 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate /* 1347c478bd9Sstevel@tonic-gate * Handles minor node type "ddi_display", in addition to generic processing 1357c478bd9Sstevel@tonic-gate * done by display(). 1367c478bd9Sstevel@tonic-gate * 1377c478bd9Sstevel@tonic-gate * This creates a /dev/vt00 link to /dev/fb, for backwards compatibility. 1387c478bd9Sstevel@tonic-gate */ 1397c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1407c478bd9Sstevel@tonic-gate int 1417c478bd9Sstevel@tonic-gate vt00(di_minor_t minor, di_node_t node) 1427c478bd9Sstevel@tonic-gate { 1437c478bd9Sstevel@tonic-gate (void) devfsadm_secondary_link("vt00", "fb", 0); 1447c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 1457c478bd9Sstevel@tonic-gate } 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate /* 1487c478bd9Sstevel@tonic-gate * type=ddi_block:diskette;addr=0,0;minor=c diskette 1497c478bd9Sstevel@tonic-gate * type=ddi_block:diskette;addr=0,0;minor=c,raw rdiskette 1507c478bd9Sstevel@tonic-gate * type=ddi_block:diskette;addr1=0;minor=c diskette\A2 1517c478bd9Sstevel@tonic-gate * type=ddi_block:diskette;addr1=0;minor=c,raw rdiskette\A2 1527c478bd9Sstevel@tonic-gate */ 1537c478bd9Sstevel@tonic-gate static int 1547c478bd9Sstevel@tonic-gate diskette(di_minor_t minor, di_node_t node) 1557c478bd9Sstevel@tonic-gate { 156*45916cd2Sjpk int flags = 0; 1577c478bd9Sstevel@tonic-gate char *a2; 1587c478bd9Sstevel@tonic-gate char link[PATH_MAX]; 1597c478bd9Sstevel@tonic-gate char *addr = di_bus_addr(node); 1607c478bd9Sstevel@tonic-gate char *mn = di_minor_name(minor); 1617c478bd9Sstevel@tonic-gate 162*45916cd2Sjpk if (system_labeled) 163*45916cd2Sjpk flags = DA_ADD|DA_FLOPPY; 164*45916cd2Sjpk 1657c478bd9Sstevel@tonic-gate if (strcmp(addr, "0,0") == 0) { 1667c478bd9Sstevel@tonic-gate if (strcmp(mn, "c") == 0) { 167*45916cd2Sjpk (void) devfsadm_mklink("diskette", node, minor, flags); 1687c478bd9Sstevel@tonic-gate } else if (strcmp(mn, "c,raw") == 0) { 169*45916cd2Sjpk (void) devfsadm_mklink("rdiskette", node, minor, flags); 1707c478bd9Sstevel@tonic-gate } 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate } 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate if (addr[0] == '0') { 1757c478bd9Sstevel@tonic-gate if ((a2 = strchr(addr, ',')) != NULL) { 1767c478bd9Sstevel@tonic-gate a2++; 1777c478bd9Sstevel@tonic-gate if (strcmp(mn, "c") == 0) { 1787c478bd9Sstevel@tonic-gate (void) strcpy(link, "diskette"); 1797c478bd9Sstevel@tonic-gate (void) strcat(link, a2); 180*45916cd2Sjpk (void) devfsadm_mklink(link, node, minor, 181*45916cd2Sjpk flags); 1827c478bd9Sstevel@tonic-gate } else if (strcmp(mn, "c,raw") == 0) { 1837c478bd9Sstevel@tonic-gate (void) strcpy(link, "rdiskette"); 1847c478bd9Sstevel@tonic-gate (void) strcat(link, a2); 185*45916cd2Sjpk (void) devfsadm_mklink(link, node, minor, 186*45916cd2Sjpk flags); 1877c478bd9Sstevel@tonic-gate } 1887c478bd9Sstevel@tonic-gate } 1897c478bd9Sstevel@tonic-gate } 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 1927c478bd9Sstevel@tonic-gate } 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate /* 1957c478bd9Sstevel@tonic-gate * type=ddi_printer;name=lp;addr=1,3bc lp0 1967c478bd9Sstevel@tonic-gate * type=ddi_printer;name=lp;addr=1,378 lp1 1977c478bd9Sstevel@tonic-gate * type=ddi_printer;name=lp;addr=1,278 lp2 1987c478bd9Sstevel@tonic-gate */ 1997c478bd9Sstevel@tonic-gate static int 2007c478bd9Sstevel@tonic-gate lp(di_minor_t minor, di_node_t node) 2017c478bd9Sstevel@tonic-gate { 2027c478bd9Sstevel@tonic-gate char *addr = di_bus_addr(node); 2037c478bd9Sstevel@tonic-gate char *buf; 2047c478bd9Sstevel@tonic-gate char path[PATH_MAX + 1]; 2057c478bd9Sstevel@tonic-gate devfsadm_enumerate_t rules[1] = {"^ecpp([0-9]+)$", 1, MATCH_ALL}; 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate if (strcmp(addr, "1,3bc") == 0) { 2087c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("lp0", node, minor, 0); 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate } else if (strcmp(addr, "1,378") == 0) { 2117c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("lp1", node, minor, 0); 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate } else if (strcmp(addr, "1,278") == 0) { 2147c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("lp2", node, minor, 0); 2157c478bd9Sstevel@tonic-gate } 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate if (strcmp(di_driver_name(node), "ecpp") != 0) { 2187c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 2197c478bd9Sstevel@tonic-gate } 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate if ((buf = di_devfs_path(node)) == NULL) { 2227c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 2237c478bd9Sstevel@tonic-gate } 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate (void) snprintf(path, sizeof (path), "%s:%s", 2267c478bd9Sstevel@tonic-gate buf, di_minor_name(minor)); 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate di_devfs_path_free(buf); 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate if (devfsadm_enumerate_int(path, 0, &buf, rules, 1)) { 2317c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 2327c478bd9Sstevel@tonic-gate } 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate (void) snprintf(path, sizeof (path), "ecpp%s", buf); 2357c478bd9Sstevel@tonic-gate free(buf); 2367c478bd9Sstevel@tonic-gate (void) devfsadm_mklink(path, node, minor, 0); 2377c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 2387c478bd9Sstevel@tonic-gate } 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate /* 2417c478bd9Sstevel@tonic-gate * type=ddi_serial:mb;minor=a tty00 2427c478bd9Sstevel@tonic-gate * type=ddi_serial:mb;minor=b tty01 2437c478bd9Sstevel@tonic-gate * type=ddi_serial:mb;minor=c tty02 2447c478bd9Sstevel@tonic-gate * type=ddi_serial:mb;minor=d tty03 2457c478bd9Sstevel@tonic-gate */ 2467c478bd9Sstevel@tonic-gate static int 2477c478bd9Sstevel@tonic-gate serial(di_minor_t minor, di_node_t node) 2487c478bd9Sstevel@tonic-gate { 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate char *mn = di_minor_name(minor); 2517c478bd9Sstevel@tonic-gate char link[PATH_MAX]; 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate (void) strcpy(link, "tty"); 2547c478bd9Sstevel@tonic-gate (void) strcat(link, mn); 2557c478bd9Sstevel@tonic-gate (void) devfsadm_mklink(link, node, minor, 0); 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate if (strcmp(mn, "a") == 0) { 2587c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("tty00", node, minor, 0); 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate } else if (strcmp(mn, "b") == 0) { 2617c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("tty01", node, minor, 0); 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate } else if (strcmp(mn, "c") == 0) { 2647c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("tty02", node, minor, 0); 2657c478bd9Sstevel@tonic-gate 2667c478bd9Sstevel@tonic-gate } else if (strcmp(mn, "d") == 0) { 2677c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("tty03", node, minor, 0); 2687c478bd9Sstevel@tonic-gate } 2697c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 2707c478bd9Sstevel@tonic-gate } 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate /* 2737c478bd9Sstevel@tonic-gate * type=ddi_serial:dialout,mb;minor=a,cu ttyd0 2747c478bd9Sstevel@tonic-gate * type=ddi_serial:dialout,mb;minor=b,cu ttyd1 2757c478bd9Sstevel@tonic-gate * type=ddi_serial:dialout,mb;minor=c,cu ttyd2 2767c478bd9Sstevel@tonic-gate * type=ddi_serial:dialout,mb;minor=d,cu ttyd3 2777c478bd9Sstevel@tonic-gate */ 2787c478bd9Sstevel@tonic-gate static int 2797c478bd9Sstevel@tonic-gate serial_dialout(di_minor_t minor, di_node_t node) 2807c478bd9Sstevel@tonic-gate { 2817c478bd9Sstevel@tonic-gate char *mn = di_minor_name(minor); 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate if (strcmp(mn, "a,cu") == 0) { 2847c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("ttyd0", node, minor, 0); 2857c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("cua0", node, minor, 0); 2867c478bd9Sstevel@tonic-gate 2877c478bd9Sstevel@tonic-gate } else if (strcmp(mn, "b,cu") == 0) { 2887c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("ttyd1", node, minor, 0); 2897c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("cua1", node, minor, 0); 2907c478bd9Sstevel@tonic-gate 2917c478bd9Sstevel@tonic-gate } else if (strcmp(mn, "c,cu") == 0) { 2927c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("ttyd2", node, minor, 0); 2937c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("cua2", node, minor, 0); 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate } else if (strcmp(mn, "d,cu") == 0) { 2967c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("ttyd3", node, minor, 0); 2977c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("cua3", node, minor, 0); 2987c478bd9Sstevel@tonic-gate } 2997c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 3007c478bd9Sstevel@tonic-gate } 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate static int 3037c478bd9Sstevel@tonic-gate kdmouse(di_minor_t minor, di_node_t node) 3047c478bd9Sstevel@tonic-gate { 3057c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("kdmouse", node, minor, 0); 3067c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 3077c478bd9Sstevel@tonic-gate } 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate static int 3107c478bd9Sstevel@tonic-gate bmc(di_minor_t minor, di_node_t node) 3117c478bd9Sstevel@tonic-gate { 3127c478bd9Sstevel@tonic-gate (void) devfsadm_mklink("bmc", node, minor, 0); 3137c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 3147c478bd9Sstevel@tonic-gate } 31584ab085aSmws 31684ab085aSmws static int 31784ab085aSmws smbios(di_minor_t minor, di_node_t node) 31884ab085aSmws { 31984ab085aSmws (void) devfsadm_mklink("smbios", node, minor, 0); 32084ab085aSmws return (DEVFSADM_CONTINUE); 32184ab085aSmws } 32284ab085aSmws 3237c478bd9Sstevel@tonic-gate static int 3247c478bd9Sstevel@tonic-gate agp_process(di_minor_t minor, di_node_t node) 3257c478bd9Sstevel@tonic-gate { 3267c478bd9Sstevel@tonic-gate char *minor_nm, *drv_nm; 3277c478bd9Sstevel@tonic-gate char *devfspath; 3287c478bd9Sstevel@tonic-gate char *I_path, *p_path, *buf; 3297c478bd9Sstevel@tonic-gate char *name = (char *)NULL; 3307c478bd9Sstevel@tonic-gate int i, index; 3317c478bd9Sstevel@tonic-gate devfsadm_enumerate_t rules[1]; 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate minor_nm = di_minor_name(minor); 3347c478bd9Sstevel@tonic-gate drv_nm = di_driver_name(node); 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate if ((minor_nm == NULL) || (drv_nm == NULL)) { 3377c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 3387c478bd9Sstevel@tonic-gate } 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, "agp_process: minor=%s node=%s\n", 3417c478bd9Sstevel@tonic-gate minor_nm, di_node_name(node)); 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate devfspath = di_devfs_path(node); 3447c478bd9Sstevel@tonic-gate if (devfspath == NULL) { 3457c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, "agp_process: devfspath is NULL\n"); 3467c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 3477c478bd9Sstevel@tonic-gate } 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate I_path = (char *)malloc(PATH_MAX); 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate if (I_path == NULL) { 3527c478bd9Sstevel@tonic-gate di_devfs_path_free(devfspath); 3537c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, "agp_process: malloc failed\n"); 3547c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 3557c478bd9Sstevel@tonic-gate } 3567c478bd9Sstevel@tonic-gate 3577c478bd9Sstevel@tonic-gate p_path = (char *)malloc(PATH_MAX); 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate if (p_path == NULL) { 3607c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, "agp_process: malloc failed\n"); 3617c478bd9Sstevel@tonic-gate di_devfs_path_free(devfspath); 3627c478bd9Sstevel@tonic-gate free(I_path); 3637c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 3647c478bd9Sstevel@tonic-gate } 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate (void) strlcpy(p_path, devfspath, PATH_MAX); 3677c478bd9Sstevel@tonic-gate (void) strlcat(p_path, ":", PATH_MAX); 3687c478bd9Sstevel@tonic-gate (void) strlcat(p_path, minor_nm, PATH_MAX); 3697c478bd9Sstevel@tonic-gate di_devfs_path_free(devfspath); 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, "agp_process: path %s\n", p_path); 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate for (i = 0; ; i++) { 3747c478bd9Sstevel@tonic-gate if ((driver_name_table[i].driver_name == NULL) || 3757c478bd9Sstevel@tonic-gate (strcmp(drv_nm, driver_name_table[i].driver_name) == 0)) { 3767c478bd9Sstevel@tonic-gate index = driver_name_table[i].index; 3777c478bd9Sstevel@tonic-gate break; 3787c478bd9Sstevel@tonic-gate } 3797c478bd9Sstevel@tonic-gate } 3807c478bd9Sstevel@tonic-gate switch (index) { 3817c478bd9Sstevel@tonic-gate case DRIVER_AGPPSEUDO: 3827c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, 3837c478bd9Sstevel@tonic-gate "agp_process: psdeudo driver name\n"); 3847c478bd9Sstevel@tonic-gate name = "agpgart"; 3857c478bd9Sstevel@tonic-gate (void) snprintf(I_path, PATH_MAX, "%s", name); 3867c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, 3877c478bd9Sstevel@tonic-gate "mklink %s -> %s\n", I_path, p_path); 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate (void) devfsadm_mklink(I_path, node, minor, 0); 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate free(I_path); 3927c478bd9Sstevel@tonic-gate free(p_path); 3937c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 3947c478bd9Sstevel@tonic-gate case DRIVER_AGPTARGET: 3957c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, 3967c478bd9Sstevel@tonic-gate "agp_process: target driver name\n"); 3977c478bd9Sstevel@tonic-gate rules[0] = agptarget_rules[0]; 3987c478bd9Sstevel@tonic-gate name = "agptarget"; 3997c478bd9Sstevel@tonic-gate break; 4007c478bd9Sstevel@tonic-gate case DRIVER_CPUGART: 4017c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, 4027c478bd9Sstevel@tonic-gate "agp_process: cpugart driver name\n"); 4037c478bd9Sstevel@tonic-gate rules[0] = cpugart_rules[0]; 4047c478bd9Sstevel@tonic-gate name = "cpugart"; 4057c478bd9Sstevel@tonic-gate break; 4067c478bd9Sstevel@tonic-gate case DRIVER_AGPMASTER: 4077c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, 4087c478bd9Sstevel@tonic-gate "agp_process: agpmaster driver name\n"); 4097c478bd9Sstevel@tonic-gate rules[0] = agpmaster_rules[0]; 4107c478bd9Sstevel@tonic-gate name = "agpmaster"; 4117c478bd9Sstevel@tonic-gate break; 4127c478bd9Sstevel@tonic-gate case DRIVER_UNKNOWN: 4137c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, 4147c478bd9Sstevel@tonic-gate "agp_process: unknown driver name=%s\n", drv_nm); 4157c478bd9Sstevel@tonic-gate free(I_path); 4167c478bd9Sstevel@tonic-gate free(p_path); 4177c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 4187c478bd9Sstevel@tonic-gate } 4197c478bd9Sstevel@tonic-gate 4207c478bd9Sstevel@tonic-gate if (devfsadm_enumerate_int(p_path, 0, &buf, rules, 1)) { 4217c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, "agp_process: exit/coninue\n"); 4227c478bd9Sstevel@tonic-gate free(I_path); 4237c478bd9Sstevel@tonic-gate free(p_path); 4247c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 4257c478bd9Sstevel@tonic-gate } 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate (void) snprintf(I_path, PATH_MAX, "agp/%s%s", name, buf); 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, "agp_process: p_path=%s buf=%s\n", 4317c478bd9Sstevel@tonic-gate p_path, buf); 4327c478bd9Sstevel@tonic-gate 4337c478bd9Sstevel@tonic-gate free(buf); 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate devfsadm_print(debug_mid, "mklink %s -> %s\n", I_path, p_path); 4367c478bd9Sstevel@tonic-gate 4377c478bd9Sstevel@tonic-gate (void) devfsadm_mklink(I_path, node, minor, 0); 4387c478bd9Sstevel@tonic-gate 4397c478bd9Sstevel@tonic-gate free(p_path); 4407c478bd9Sstevel@tonic-gate free(I_path); 4417c478bd9Sstevel@tonic-gate 4427c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 4437c478bd9Sstevel@tonic-gate } 4447aec1d6eScindi 4457aec1d6eScindi /* 4467aec1d6eScindi * /dev/mc/mc<chipid> -> /devices/.../pci1022,1102@<chipid+24>,2:mc-amd 4477aec1d6eScindi */ 4487aec1d6eScindi static int 4497aec1d6eScindi mc_node(di_minor_t minor, di_node_t node) 4507aec1d6eScindi { 4517aec1d6eScindi const char *minorname = di_minor_name(minor); 4527aec1d6eScindi const char *busaddr = di_bus_addr(node); 4537aec1d6eScindi char linkpath[PATH_MAX]; 4547aec1d6eScindi int unitaddr; 4557aec1d6eScindi char *c; 4567aec1d6eScindi 4577aec1d6eScindi if (minorname == NULL || busaddr == NULL) 4587aec1d6eScindi return (DEVFSADM_CONTINUE); 4597aec1d6eScindi 4607aec1d6eScindi errno = 0; 4617aec1d6eScindi unitaddr = strtol(busaddr, &c, 16); 4627aec1d6eScindi 4637aec1d6eScindi if (errno != 0 || unitaddr < MC_AMD_DEV_OFFSET) 4647aec1d6eScindi return (DEVFSADM_CONTINUE); 4657aec1d6eScindi 4667aec1d6eScindi (void) snprintf(linkpath, sizeof (linkpath), "mc/mc%u", 4677aec1d6eScindi unitaddr - MC_AMD_DEV_OFFSET); 4687aec1d6eScindi (void) devfsadm_mklink(linkpath, node, minor, 0); 4697aec1d6eScindi return (DEVFSADM_CONTINUE); 4707aec1d6eScindi } 471