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