2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 /*
29 * ppm driver subroutines
30 */
31
32 #include <sys/open.h>
33 #include <sys/file.h>
34 #include <sys/conf.h>
35 #include <sys/epm.h>
36 #include <sys/sunldi.h>
37 #include <sys/ppmvar.h>
38 #include <sys/ppmio.h>
39 #include <sys/promif.h>
40 #include <sys/ddi_impldefs.h>
41 #include <sys/ddi.h>
42 #include <sys/sunddi.h>
43 /*
44 * Append address to the device path, if it is set. Routine
45 * ddi_pathname does not look for device address if the node is in
46 * DS_INITIALIZED state.
47 */
382 while (dc) {
383 ppm_print_dc(dc);
384 dc = dc->next;
385 }
386 #endif
387 }
388
389 return (DDI_SUCCESS);
390 }
391
392
393 /*
394 * scan conf devices within each domain for a matching device name
395 */
396 ppm_domain_t *
397 ppm_lookup_dev(dev_info_t *dip)
398 {
399 char path[MAXNAMELEN];
400 ppm_domain_t *domp;
401 ppm_db_t *dbp;
402
403 PPM_GET_PATHNAME(dip, path);
404 for (domp = ppm_domain_p; domp; domp = domp->next) {
405 if (PPM_DOMAIN_UP(domp)) {
406 for (dbp = domp->conflist; dbp; dbp = dbp->next) {
407 /*
408 * allow claiming root without knowing
409 * its full name
410 */
411 if (dip == ddi_root_node() &&
412 strcmp(dbp->name, "/") == 0)
413 return (domp);
414 if (ppm_match_devs(path, dbp) == 0)
415 return (domp);
416 }
417 }
418 }
419
420 return (NULL);
421 }
422
423
424 /*
425 * check ppm.conf file domain device pathname syntax, if correct,
426 * create device match pattern.
427 * return 1 for good, -1 for bad.
428 */
429 ppm_db_t *
430 ppm_parse_pattern(struct ppm_db **dbpp, char *dev_path)
431 {
432 char path[MAXNAMELEN];
433 int wccnt, i;
|
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * ppm driver subroutines
28 */
29
30 #include <sys/open.h>
31 #include <sys/file.h>
32 #include <sys/conf.h>
33 #include <sys/epm.h>
34 #include <sys/sunldi.h>
35 #include <sys/ppmvar.h>
36 #include <sys/ppmio.h>
37 #include <sys/promif.h>
38 #include <sys/ddi_impldefs.h>
39 #include <sys/ddi.h>
40 #include <sys/sunddi.h>
41 /*
42 * Append address to the device path, if it is set. Routine
43 * ddi_pathname does not look for device address if the node is in
44 * DS_INITIALIZED state.
45 */
380 while (dc) {
381 ppm_print_dc(dc);
382 dc = dc->next;
383 }
384 #endif
385 }
386
387 return (DDI_SUCCESS);
388 }
389
390
391 /*
392 * scan conf devices within each domain for a matching device name
393 */
394 ppm_domain_t *
395 ppm_lookup_dev(dev_info_t *dip)
396 {
397 char path[MAXNAMELEN];
398 ppm_domain_t *domp;
399 ppm_db_t *dbp;
400 #ifdef __x86
401 char *devtype = NULL;
402 #endif /* __x86 */
403
404 PPM_GET_PATHNAME(dip, path);
405 for (domp = ppm_domain_p; domp; domp = domp->next) {
406 if (PPM_DOMAIN_UP(domp)) {
407 for (dbp = domp->conflist; dbp; dbp = dbp->next) {
408 /*
409 * allow claiming root without knowing
410 * its full name
411 */
412 if (dip == ddi_root_node() &&
413 strcmp(dbp->name, "/") == 0)
414 return (domp);
415
416 #ifdef __x86
417 /*
418 * Special rule to catch all CPU devices on x86.
419 */
420 if (domp->model == PPMD_CPU &&
421 strcmp(dbp->name, "/") == 0 &&
422 ddi_prop_lookup_string(DDI_DEV_T_ANY, dip,
423 DDI_PROP_DONTPASS, "device_type",
424 &devtype) == DDI_SUCCESS) {
425 if (strcmp(devtype, "cpu") == 0) {
426 ddi_prop_free(devtype);
427 return (domp);
428 } else {
429 ddi_prop_free(devtype);
430 }
431 }
432 #endif /* __x86 */
433
434 if (ppm_match_devs(path, dbp) == 0)
435 return (domp);
436 }
437 }
438 }
439
440 return (NULL);
441 }
442
443
444 /*
445 * check ppm.conf file domain device pathname syntax, if correct,
446 * create device match pattern.
447 * return 1 for good, -1 for bad.
448 */
449 ppm_db_t *
450 ppm_parse_pattern(struct ppm_db **dbpp, char *dev_path)
451 {
452 char path[MAXNAMELEN];
453 int wccnt, i;
|