summaryrefslogtreecommitdiff
path: root/usr/src/uts/sun4u/opl/sys/pcicmu/pcmu_util.h
blob: 31ba222cd1df4d674f9b61eee34975497942e737 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_PCMU_UTIL_H
#define	_SYS_PCMU_UTIL_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif


/*
 * Prototypes
 */
extern int pcmu_init_child(pcmu_t *, dev_info_t *);
extern int pcmu_uninit_child(pcmu_t *, dev_info_t *);
extern int pcmu_report_dev(dev_info_t *);
extern int get_pcmu_properties(pcmu_t *, dev_info_t *);
extern void free_pcmu_properties(pcmu_t *);
extern int pcmu_get_portid(dev_info_t *);
extern int pcmu_reloc_reg(dev_info_t *, dev_info_t *, pcmu_t *,
    pci_regspec_t *);
extern int pcmu_xlate_reg(pcmu_t *, pci_regspec_t *, struct regspec *);
extern off_t pcmu_get_reg_set_size(dev_info_t *, int);
extern uint_t pcmu_get_nreg_set(dev_info_t *);
extern uint64_t pcmu_get_cfg_pabase(pcmu_t *);
extern int pcmu_cfg_report(dev_info_t *, ddi_fm_error_t *,
    pcmu_errstate_t *, int, uint32_t);

#ifdef DEBUG

extern uint64_t pcmu_debug_flags;

typedef struct pcmu_dflag_to_str {
	uint64_t flag;
	char *string;
} pcmu_dflag_to_str_t;

#define	PCMU_DBG_ATTACH		0x1ull
#define	PCMU_DBG_DETACH		0x2ull
#define	PCMU_DBG_MAP		0x4ull
#define	PCMU_DBG_A_INTX		0x8ull
#define	PCMU_DBG_R_INTX		0x10ull
#define	PCMU_DBG_INIT_CLD	0x20ull
#define	PCMU_DBG_CTLOPS		0x40ull
#define	PCMU_DBG_INTR		0x80ull
#define	PCMU_DBG_ERR_INTR	0x100ull
#define	PCMU_DBG_BUS_FAULT	0x200ull
#define	PCMU_DBG_IB		(0x20ull << 32)
#define	PCMU_DBG_CB		(0x40ull << 32)
#define	PCMU_DBG_PBM		(0x80ull << 32)
#define	PCMU_DBG_CONT		(0x100ull << 32)
#define	PCMU_DBG_OPEN		(0x1000ull << 32)
#define	PCMU_DBG_CLOSE		(0x2000ull << 32)
#define	PCMU_DBG_IOCTL		(0x4000ull << 32)
#define	PCMU_DBG_PWR		(0x8000ull << 32)


#define	PCMU_DBG0(flag, dip, fmt)	\
	pcmu_debug(flag, dip, fmt, 0, 0, 0, 0, 0);

#define	PCMU_DBG1(flag, dip, fmt, a1)	\
	pcmu_debug(flag, dip, fmt, (uintptr_t)(a1), 0, 0, 0, 0);

#define	PCMU_DBG2(flag, dip, fmt, a1, a2)	\
	pcmu_debug(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0);

#define	PCMU_DBG3(flag, dip, fmt, a1, a2, a3)	\
	pcmu_debug(flag, dip, fmt, (uintptr_t)(a1),	\
		(uintptr_t)(a2), (uintptr_t)(a3), 0, 0);

#define	PCMU_DBG4(flag, dip, fmt, a1, a2, a3, a4)	\
	pcmu_debug(flag, dip, fmt, (uintptr_t)(a1),	\
		(uintptr_t)(a2), (uintptr_t)(a3), \
		(uintptr_t)(a4), 0);

#define	PCMU_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5)	\
	pcmu_debug(flag, dip, fmt, (uintptr_t)(a1),	\
		(uintptr_t)(a2), (uintptr_t)(a3), \
		(uintptr_t)(a4), (uintptr_t)(a5));

extern void pcmu_debug(uint64_t, dev_info_t *, char *,
			uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
#else /* DEBUG */

#define	PCMU_DBG0(flag, dip, fmt)
#define	PCMU_DBG1(flag, dip, fmt, a1)
#define	PCMU_DBG2(flag, dip, fmt, a1, a2)
#define	PCMU_DBG3(flag, dip, fmt, a1, a2, a3)
#define	PCMU_DBG4(flag, dip, fmt, a1, a2, a3, a4)
#define	PCMU_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5)

#endif /* DEBUG */

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_PCMU_UTIL_H */