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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/types.h>
26 #include <sys/mkdev.h>
27 #include <sys/stat.h>
28 #include <sys/sunddi.h>
29 #include <vm/seg_kmem.h>
30 #include <sys/machparam.h>
31 #include <sys/sunndi.h>
32 #include <sys/ontrap.h>
33 #include <sys/psm.h>
34 #include <sys/pcie.h>
35 #include <sys/pci_cfgspace.h>
36 #include <sys/pci_tools.h>
37 #include <io/pci/pci_tools_ext.h>
38 #include <sys/apic.h>
39 #include <sys/apix.h>
40 #include <io/pci/pci_var.h>
41 #include <sys/pci_impl.h>
42 #include <sys/promif.h>
43 #include <sys/x86_archext.h>
44 #include <sys/cpuvar.h>
571 *
572 * X86 systems on which this module was tested return FFs instead of bus errors
573 * when accessing devices with invalid addresses. Ontrap handling, which
574 * gracefully handles kernel bus errors, is installed anyway for I/O and mem
575 * space accessing (not for pci config space), in case future X86 platforms
576 * require it.
577 */
578
579 /* Access device. prg is modified. */
580 static int
581 pcitool_cfg_access(pcitool_reg_t *prg, boolean_t write_flag,
582 boolean_t io_access)
583 {
584 int size = PCITOOL_ACC_ATTR_SIZE(prg->acc_attr);
585 boolean_t big_endian = PCITOOL_ACC_IS_BIG_ENDIAN(prg->acc_attr);
586 int rval = SUCCESS;
587 uint64_t local_data;
588 pci_cfgacc_req_t req;
589 uint32_t max_offset;
590
591 if ((size <= 0) || (size > 8) || ((size & (size - 1)) != 0)) {
592 prg->status = PCITOOL_INVALID_SIZE;
593 return (ENOTSUP);
594 }
595
596 /*
597 * NOTE: there is no way to verify whether or not the address is
598 * valid other than that it is within the maximum offset. The
599 * put functions return void and the get functions return -1 on error.
600 */
601
602 if (io_access)
603 max_offset = 0xFF;
604 else
605 max_offset = 0xFFF;
606 if (prg->offset + size - 1 > max_offset) {
607 prg->status = PCITOOL_INVALID_ADDRESS;
608 return (ENOTSUP);
609 }
610
611 prg->status = PCITOOL_SUCCESS;
|
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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/sysmacros.h>
26 #include <sys/types.h>
27 #include <sys/mkdev.h>
28 #include <sys/stat.h>
29 #include <sys/sunddi.h>
30 #include <vm/seg_kmem.h>
31 #include <sys/machparam.h>
32 #include <sys/sunndi.h>
33 #include <sys/ontrap.h>
34 #include <sys/psm.h>
35 #include <sys/pcie.h>
36 #include <sys/pci_cfgspace.h>
37 #include <sys/pci_tools.h>
38 #include <io/pci/pci_tools_ext.h>
39 #include <sys/apic.h>
40 #include <sys/apix.h>
41 #include <io/pci/pci_var.h>
42 #include <sys/pci_impl.h>
43 #include <sys/promif.h>
44 #include <sys/x86_archext.h>
45 #include <sys/cpuvar.h>
572 *
573 * X86 systems on which this module was tested return FFs instead of bus errors
574 * when accessing devices with invalid addresses. Ontrap handling, which
575 * gracefully handles kernel bus errors, is installed anyway for I/O and mem
576 * space accessing (not for pci config space), in case future X86 platforms
577 * require it.
578 */
579
580 /* Access device. prg is modified. */
581 static int
582 pcitool_cfg_access(pcitool_reg_t *prg, boolean_t write_flag,
583 boolean_t io_access)
584 {
585 int size = PCITOOL_ACC_ATTR_SIZE(prg->acc_attr);
586 boolean_t big_endian = PCITOOL_ACC_IS_BIG_ENDIAN(prg->acc_attr);
587 int rval = SUCCESS;
588 uint64_t local_data;
589 pci_cfgacc_req_t req;
590 uint32_t max_offset;
591
592 if ((size <= 0) || (size > 8) || !ISP2(size)) {
593 prg->status = PCITOOL_INVALID_SIZE;
594 return (ENOTSUP);
595 }
596
597 /*
598 * NOTE: there is no way to verify whether or not the address is
599 * valid other than that it is within the maximum offset. The
600 * put functions return void and the get functions return -1 on error.
601 */
602
603 if (io_access)
604 max_offset = 0xFF;
605 else
606 max_offset = 0xFFF;
607 if (prg->offset + size - 1 > max_offset) {
608 prg->status = PCITOOL_INVALID_ADDRESS;
609 return (ENOTSUP);
610 }
611
612 prg->status = PCITOOL_SUCCESS;
|