1 /*
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 (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24 /*
25 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
27 * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
28 * Copyright 2017 Joyent, Inc.
29 */
30
31 /*
32 * x86 root nexus driver
33 */
34
35 #include <sys/sysmacros.h>
36 #include <sys/conf.h>
37 #include <sys/autoconf.h>
38 #include <sys/sysmacros.h>
39 #include <sys/debug.h>
40 #include <sys/psw.h>
41 #include <sys/ddidmareq.h>
42 #include <sys/promif.h>
43 #include <sys/devops.h>
44 #include <sys/kmem.h>
45 #include <sys/cmn_err.h>
715 */
716 if ((pdp = ddi_get_parent_data(rdip)) == NULL)
717 return (DDI_FAILURE);
718
719 if (ctlop == DDI_CTLOPS_NREGS) {
720 ptr = (int *)result;
721 *ptr = pdp->par_nreg;
722 } else {
723 off_t *size = (off_t *)result;
724
725 ptr = (int *)arg;
726 n = *ptr;
727 if (n >= pdp->par_nreg) {
728 return (DDI_FAILURE);
729 }
730 *size = (off_t)pdp->par_reg[n].regspec_size;
731 }
732 return (DDI_SUCCESS);
733 }
734
735
736 /*
737 * rootnex_ctl_reportdev()
738 *
739 */
740 static int
741 rootnex_ctl_reportdev(dev_info_t *dev)
742 {
743 int i, n, len, f_len = 0;
744 char *buf;
745
746 buf = kmem_alloc(REPORTDEV_BUFSIZE, KM_SLEEP);
747 f_len += snprintf(buf, REPORTDEV_BUFSIZE,
748 "%s%d at root", ddi_driver_name(dev), ddi_get_instance(dev));
749 len = strlen(buf);
750
751 for (i = 0; i < sparc_pd_getnreg(dev); i++) {
752
753 struct regspec *rp = sparc_pd_getreg(dev, i);
754
755 if (i == 0)
756 f_len += snprintf(buf + len, REPORTDEV_BUFSIZE - len,
757 ": ");
758 else
759 f_len += snprintf(buf + len, REPORTDEV_BUFSIZE - len,
760 " and ");
761 len = strlen(buf);
762
763 switch (rp->regspec_bustype) {
764
765 case BTEISA:
766 f_len += snprintf(buf + len, REPORTDEV_BUFSIZE - len,
767 "%s 0x%x", DEVI_EISA_NEXNAME, rp->regspec_addr);
768 break;
769
770 case BTISA:
771 f_len += snprintf(buf + len, REPORTDEV_BUFSIZE - len,
772 "%s 0x%x", DEVI_ISA_NEXNAME, rp->regspec_addr);
773 break;
774
775 default:
776 f_len += snprintf(buf + len, REPORTDEV_BUFSIZE - len,
777 "space %x offset %x",
778 rp->regspec_bustype, rp->regspec_addr);
779 break;
780 }
781 len = strlen(buf);
782 }
783 for (i = 0, n = sparc_pd_getnintr(dev); i < n; i++) {
784 int pri;
785
786 if (i != 0) {
787 f_len += snprintf(buf + len, REPORTDEV_BUFSIZE - len,
788 ",");
789 len = strlen(buf);
790 }
791 pri = INT_IPL(sparc_pd_getintr(dev, i)->intrspec_pri);
792 f_len += snprintf(buf + len, REPORTDEV_BUFSIZE - len,
793 " sparc ipl %d", pri);
794 len = strlen(buf);
795 }
796 #ifdef DEBUG
797 if (f_len + 1 >= REPORTDEV_BUFSIZE) {
798 cmn_err(CE_NOTE, "next message is truncated: "
799 "printed length 1024, real length %d", f_len);
800 }
801 #endif /* DEBUG */
802 cmn_err(CE_CONT, "?%s\n", buf);
803 kmem_free(buf, REPORTDEV_BUFSIZE);
804 return (DDI_SUCCESS);
805 }
806
807
808 /*
809 * ******************
810 * map related code
811 * ******************
812 */
813
814 /*
815 * rootnex_map()
816 *
817 */
818 static int
819 rootnex_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
820 off_t len, caddr_t *vaddrp)
821 {
822 struct regspec *orp = NULL;
823 struct regspec64 rp = { 0 };
|
1 /*
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 /*
23 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 /*
27 * Copyright 2018 Nexenta Systems, Inc.
28 * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
29 * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
30 * Copyright 2017 Joyent, Inc.
31 */
32
33 /*
34 * x86 root nexus driver
35 */
36
37 #include <sys/sysmacros.h>
38 #include <sys/conf.h>
39 #include <sys/autoconf.h>
40 #include <sys/sysmacros.h>
41 #include <sys/debug.h>
42 #include <sys/psw.h>
43 #include <sys/ddidmareq.h>
44 #include <sys/promif.h>
45 #include <sys/devops.h>
46 #include <sys/kmem.h>
47 #include <sys/cmn_err.h>
717 */
718 if ((pdp = ddi_get_parent_data(rdip)) == NULL)
719 return (DDI_FAILURE);
720
721 if (ctlop == DDI_CTLOPS_NREGS) {
722 ptr = (int *)result;
723 *ptr = pdp->par_nreg;
724 } else {
725 off_t *size = (off_t *)result;
726
727 ptr = (int *)arg;
728 n = *ptr;
729 if (n >= pdp->par_nreg) {
730 return (DDI_FAILURE);
731 }
732 *size = (off_t)pdp->par_reg[n].regspec_size;
733 }
734 return (DDI_SUCCESS);
735 }
736
737 /*ARGSUSED*/
738 static int
739 rootnex_ctl_reportdev(dev_info_t *dev)
740 {
741 return (DDI_SUCCESS);
742 }
743
744
745 /*
746 * ******************
747 * map related code
748 * ******************
749 */
750
751 /*
752 * rootnex_map()
753 *
754 */
755 static int
756 rootnex_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, off_t offset,
757 off_t len, caddr_t *vaddrp)
758 {
759 struct regspec *orp = NULL;
760 struct regspec64 rp = { 0 };
|