xref: /titanic_50/usr/src/cmd/pcitool/pcitool_ui.h (revision 0a0e9771ca0211c15f3ac4466b661c145feeb9e4)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_PCITOOL_UI_H
27 #define	_PCITOOL_UI_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * This defines the interface between the pcitool_ui.c module which parses the
35  * commandline options, and the other pcitool modules which process them.
36  */
37 #define	SUCCESS	0	/* This does not conflict with errno values. */
38 #define	FAILURE	-1	/* General failure. */
39 
40 /*
41  * Flags which get set in the flags field of pcitool_uiargs_t. There is a flag
42  * for each option specified on the commandline.
43  */
44 #define	NEXUS_FLAG	0x1
45 #define	LEAF_FLAG	0x2
46 #define	INTR_FLAG	0x4		/* Either -i or -m specified */
47 #define	PROBEDEV_FLAG	0x8		/* Probe a specific device */
48 #define	PROBETREE_FLAG	0x10		/* Probe all devs on a tree */
49 #define	PROBEALL_FLAG	0x20		/* Probe devs on all trees */
50 #define	PROBERNG_FLAG	0x40		/* Probe devs within bus ranges */
51 					/* - mod to PROBEALL and PROBETREE */
52 #define	PROBE_FLAGS	(PROBEDEV_FLAG | PROBETREE_FLAG | PROBEALL_FLAG | \
53 				PROBERNG_FLAG)
54 #define	ALL_COMMANDS	(NEXUS_FLAG | LEAF_FLAG | INTR_FLAG | PROBE_FLAGS)
55 #define	READ_FLAG	0x80
56 #define	WRITE_FLAG	0x100
57 #define	OFFSET_FLAG	0x200
58 #define	SIZE_FLAG	0x400
59 #define	ENDIAN_FLAG	0x800
60 #define	BYTEDUMP_FLAG	0x1000
61 #define	CHARDUMP_FLAG	0x2000
62 #define	ERRCONT_FLAG	0x4000
63 #define	VERBOSE_FLAG	0x8000
64 #define	QUIET_FLAG	0x10000
65 #define	LOOP_FLAG	0x20000
66 #define	SHOWCTLR_FLAG	0x40000
67 #define	SETGRP_FLAG	0x80000
68 
69 /* Values specified by suboption parser. */
70 #define	BANK_SPEC_FLAG	(0x10000ULL << 32)
71 #define	BASE_SPEC_FLAG	(0x20000ULL << 32)
72 #define	BUS_SPEC_FLAG	(0x40000ULL << 32)
73 #define	DEV_SPEC_FLAG	(0x80000ULL << 32)
74 #define	FUNC_SPEC_FLAG	(0x100000ULL << 32)
75 #define	CPU_SPEC_FLAG	(0x200000ULL << 32)	/* -w <cpu#> */
76 #define	INO_ALL_FLAG	(0x400000ULL << 32)	/* -i all */
77 #define	INO_SPEC_FLAG	(0x800000ULL << 32)	/* -i <#ino> */
78 #define	MSI_ALL_FLAG	(0x1000000ULL << 32)	/* -m all */
79 #define	MSI_SPEC_FLAG	(0x2000000ULL << 32)	/* -m <#msi> */
80 
81 /* Macros for a few heavily-used flags. */
82 #define	IS_VERBOSE(flags)	(flags & VERBOSE_FLAG)
83 #define	IS_QUIET(flags)		(flags & QUIET_FLAG)
84 #define	IS_LOOP(flags)		(flags & LOOP_FLAG)
85 
86 /*
87  * This is the structure of flags and parsed values returned from pcitool_ui.c
88  */
89 typedef struct uiargs {
90 	uint64_t	write_value;
91 	uint64_t	base_address;
92 	uint64_t	flags;
93 	uint32_t	offset;
94 	uint32_t	bytedump_amt;
95 	uint32_t	intr_cpu;
96 	uint8_t		bus;
97 	uint8_t		device;
98 	uint8_t		function;
99 	uint8_t		size;
100 	uint8_t		bank;
101 	uint8_t		intr_ino;
102 	uint16_t	intr_msi;
103 	boolean_t	big_endian;
104 } pcitool_uiargs_t;
105 
106 /* Exported functions. */
107 
108 int get_commandline_args(int argc, char *argv[], pcitool_uiargs_t *parsed_args);
109 void usage(char *name);
110 
111 #ifdef	__cplusplus
112 }
113 #endif
114 
115 #endif	/* _PCITOOL_UI_H */
116