xref: /illumos-gate/usr/src/uts/sun4/io/px/px_tools_var.h (revision 54719d5edb7521bb3a321ad8bd9ebc251d61a1a0)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_PX_TOOLS_VAR_H
28 #define	_SYS_PX_TOOLS_VAR_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * This file contains definitions shared between the platform specific
38  * px_tools_4[u/v].c files and px_tools.c
39  */
40 
41 /*
42  * Build device address based on base addr from range prop, and
43  * bus, dev and func values passed in.
44  */
45 #define	PX_GET_BDF(p_p)				\
46 	(((p_p)->bus_no << PCI_REG_BUS_SHIFT) +	\
47 	((p_p)->dev_no << PCI_REG_DEV_SHIFT) +	\
48 	((p_p)->func_no << PCI_REG_FUNC_SHIFT))
49 
50 /*
51  * PX hardware shifts bus / dev / function bits 4 to the left of their
52  * normal PCI placement.
53  */
54 #define	PX_PCI_BDF_OFFSET_DELTA	4
55 
56 /*
57  * Extract 64 bit parent or size values from 32 bit cells of
58  * px_ranges_t property.
59  *
60  * Only bits 42-32 are relevant in parent_high.
61  */
62 #define	PX_GET_RANGE_PROP(ranges, bank) \
63 	((((uint64_t)(ranges[bank].parent_high & 0x7ff)) << 32) | \
64 	ranges[bank].parent_low)
65 
66 #define	PX_GET_RANGE_PROP_SIZE(ranges, bank) \
67 	((((uint64_t)(ranges[bank].size_high)) << 32) | \
68 	ranges[bank].size_low)
69 
70 #define	PCI_BAR_OFFSET(x)	(pci_bars[x.barnum])
71 
72 #define	PX_ISWRITE		B_TRUE
73 #define	PX_ISREAD		B_FALSE
74 
75 #define	SUCCESS	0
76 
77 /* Exported from px_tools.c */
78 
79 extern uint8_t pci_bars[];
80 extern int pci_num_bars;
81 
82 /* pxtool internal platform spec stuff exported by px_tools_4[u/v].c files */
83 
84 extern int pxtool_num_inos;
85 
86 int pxtool_pcicfg_access(px_t *px_p, pcitool_reg_t *prg_p, uint64_t max_addr,
87     uint64_t *data_p, boolean_t is_write);
88 int pxtool_pciiomem_access(px_t *px_p, pcitool_reg_t *prg_p, uint64_t max_addr,
89     uint64_t *data_p, boolean_t is_write);
90 int pxtool_dev_reg_ops_platchk(dev_info_t *dip, pcitool_reg_t *prg_p);
91 
92 #ifdef	__cplusplus
93 }
94 #endif
95 
96 #endif	/* _SYS_PX_TOOLS_VAR_H */
97