xref: /illumos-gate/usr/src/uts/sun4/io/px/px_tools_var.h (revision 5422785d352a2bb398daceab3d1898a8aa64d006)
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 #define	PCI_BAR_OFFSET(x)	(pci_bars[x.barnum])
57 
58 #define	PX_ISWRITE		B_TRUE
59 #define	PX_ISREAD		B_FALSE
60 
61 #define	SUCCESS	0
62 
63 /* Exported from px_tools.c */
64 
65 extern uint8_t pci_bars[];
66 extern int pci_num_bars;
67 
68 /* pxtool internal platform spec stuff exported by px_tools_4[u/v].c files */
69 
70 extern int pxtool_num_inos;
71 
72 int pxtool_pcicfg_access(px_t *px_p, pcitool_reg_t *prg_p,
73     uint64_t *data_p, boolean_t is_write);
74 int pxtool_pciiomem_access(px_t *px_p, pcitool_reg_t *prg_p,
75     uint64_t *data_p, boolean_t is_write);
76 int pxtool_dev_reg_ops_platchk(dev_info_t *dip, pcitool_reg_t *prg_p);
77 
78 #ifdef	__cplusplus
79 }
80 #endif
81 
82 #endif	/* _SYS_PX_TOOLS_VAR_H */
83