xref: /titanic_50/usr/src/cmd/pcitool/pcitool_usage.c (revision 2a8d6eba033e4713ab12b61178f0513f1f075482)
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_USAGE_TEXT_H
27 #define	_PCITOOL_USAGE_TEXT_H
28 
29 #include <stdio.h>
30 
31 static char *pcitool_usage_reg[] = {
32 "Register peek/poke mode:",
33 " %s <PCI nexus node>",
34 "  [   -n bank=<register bank>",
35 "         where register bank is 0 for mapped jbus space and 1 for pcie space",
36 "         (only on applicable platforms)",
37 "",
38 "      -n base=<base address>",
39 "         where base address is a physical base address of a register bank",
40 "         (only on applicable platforms (e.g. sun4v) where bank info is "
41 	"unavailable)",
42 "",
43 "      -d bus=<bus>,dev=<dev>,func=<func>,bank=<register bank>",
44 "      -d bdf=<bus>.<dev>.<func>,bank=<register bank>",
45 "",
46 "      -d bus=<bus>,dev=<dev>,func=<func> | bdf=<bus>.<dev>.<func> ,",
47 "	  [ config | bar0 | bar1 | bar2 | bar3 | bar4 | bar5 | rom ]",
48 "	  (spaces added for clarity but are not allowed in the command)",
49 "",
50 "  -n and -d options may also include:",
51 "",
52 "  [ -w <value to write> ] [ -r ]",
53 "  [ -o <offset> ]",
54 "  [ -s 1 | 2 | 4 | 8 ]",
55 "  [ -e b | l ]",
56 "  [ -l ]",
57 "  [ -b <number bytes to dump> [ -c ] [ -x ] ]",
58 "  [ -v ]",
59 "  [ -q ]",
60 "",
61 "  -n may also include:",
62 "",
63 "  [ -y ]",
64 "",
65 "Probe mode:",
66 " %s [ <PCI nexus node> ] [ -a ] [ -p ] [ -v ] [ -q ]",
67 "",
68 " %s <PCI nexus node> [ -p [ bus=<bus>,dev=<dev>,func=<func> ] [ -v ] [ -q ]",
69 " %s <PCI nexus node> [ -p [ bdf=<bus>.<dev>.<func> ] [ -v ] [-q ]",
70 "",
71 "Probe mode",
72 "----------",
73 "",
74 "-p [ bus=<bus>,dev=<dev>,func=<func> | bdf=<bus>.<dev>.<func> ]",
75 "     Specify bus, device and/or function of devices to search for and dump.",
76 "",
77 "-a Probe all buses.  By default, pcitool checks the PCI nexus node's",
78 "bus-range property to restrict which buses are probed.  This option",
79 "cannot be combined with an explicit bus specification.",
80 "",
81 "If a PCI nexus node is specified, pcitool looks only for devices",
82 "under that node.  If no PCI nexus node is specified, pcitool looks",
83 "for devices under all PCI nexus nodes.  PCI nexus nodes, which can",
84 "be used for other pcitool commands, are printed at the top of each tree.",
85 "",
86 "Non-verbose probe mode prints config register data as follows:",
87 "  aa bb c dddd eeee ffff gggg hh iiiiii jj kk ll mm",
88 "  where...",
89 "    a = pci bus number",
90 "    b = pci device number",
91 "    c = pci function number",
92 "    d = vendor ID",
93 "    e = device ID",
94 "    f = command register",
95 "    g = status register",
96 "    h = revision ID",
97 "    i = class code",
98 "    j = cache line size",
99 "    k = latency timer",
100 "    l = header type",
101 "    m = built in self test register (bist)",
102 "",
103 "Register peek/poke mode",
104 "-----------------------",
105 "",
106 "-n requests nexus node info.",
107 "   Specify desired nexus register using -o <register offset>",
108 "",
109 "-d requests device (leaf) node info.",
110 "   Specify bus, dev, function bits (from probe mode) as hex numbers.",
111 "   Bank is specified in one of the following ways:",
112 "     By value: 0 == config space, 1 == BAR0, 2 == BAR1, ..., 6 == BAR5, "
113 	"7 == ROM",
114 "     By BAR (bus addr reg): config, bar0, bar1, bar2, bar3, bar4, bar5, rom",
115 "",
116 "Above peek/poke mode selections take the following options:",
117 "",
118 "-r for reading (default)",
119 "-w <value> for writing",
120 "-w <value> -r for writing a value followed by a readback",
121 "",
122 "-o <offset> to specify an offset within the requested address space",
123 "",
124 "-s <size specifier>: 1, 2, 4 or 8 bytes, default 4",
125 "   (8-byte transfers on supported platforms only)",
126 "",
127 "-e <endian specifier>: b or l (ell), default is l for little endian>",
128 "",
129 "-l to do repetitious accesses to/from the same location(s)",
130 "",
131 "-b <number of bytes to dump> [ -c ] to get a formatted multiple register dump",
132 "   starting at the offset given.  Hex bytes are always dumped.",
133 "   -c dumps characters as well.  "
134 	"Non-printable characters are dumped as \"@\".",
135 "   -x keeps going on errors, and prints err characters as X",
136 "",
137 "Above nexus peek/poke mode selections take the following additional option:",
138 "",
139 "-y to confirm a base_addr without being prompted interactively",
140 "",
141 "NOTE: Some platforms (i.e. SPARC) return peek/poke errors as failed ioctls;",
142 "    Other platforms (i.e. X86) return peek/poke errors as FF values.",
143 "",
144 "All numeric values are in HEX",
145 NULL
146 };
147 
148 static char *pcitool_usage_intr[] = {
149 "Usage:",
150 "Interrupt mode:",
151 " %s <PCI nexus node> -i [ ino=<ino> ] [ -r [ -c ] | -w cpu=<CPU> ]",
152 "	[ -v ] [ -q ]",
153 " (only on applicable platforms)",
154 "",
155 "where",
156 "",
157 "<PCI nexus node> is a node from /devices, with \"/devices\" stripped off.",
158 "For example: /pci@1e,600000",
159 "",
160 "-v gives verbose output for all modes.",
161 "",
162 "-q suppresses error output (except for commandline parsing errors) for all "
163 	"modes",
164 "   (Note that errno status is returned to the shell upon termination.)",
165 "",
166 "Online help mode:",
167 " %s -h",
168 "   Prints this message.",
169 "",
170 "Interrupt mode",
171 "--------------",
172 "",
173 "-i [ ino=<ino> ] changes or retrieves current CPU for interrupts of given",
174 "nexus and optionally given ino.  Ino must be selected if -w specified.",
175 "If no ino is selected (as for displaying), all will be selected.",
176 "",
177 "-w cpu=<CPU> [ -g ] to change an ino<->CPU binding.",
178 "",
179 "   Note: On certain platforms (e.g. X86), multiple MSI interrupts of a single",
180 "   function need to be moved together.  Use -g to do this.  -g works only on",
181 "   supported platforms and only for groups of MSI interrupts.  When -g is",
182 "   used, ino must be the lowest-numbered vector of the group.  (Use the mdb",
183 "   ::interrupts dcmd to discover groups of MSI vectors.)  The size of the",
184 "   group is determined internally.  (\"Groups\" of size 1 are accepted.)",
185 "",
186 "-r [ -c ] for displaying ino<->CPU bindings of all selected inos on a given",
187 "   nexus.  -c optionally dumps controller information.",
188 "",
189 "   All relevant enabled inos supporting non-nexus device interrupts will be",
190 "   printed.  For each printed ino, all supported devices and their CPU",
191 "   binding will be displayed.  On some platforms, inos dedicated to the root",
192 "   nexus will be shown and marked with \"(Internal)\".",
193 "",
194 "When neither -r nor -w are specified, -r is the default.",
195 NULL
196 };
197 
198 
199 /*
200  * Print usage statement.
201  *
202  * Text is too large for many print statements.
203  *
204  * Instead, loop through the array of strings in pcitool_usage_text.
205  * Print program name when %s is in the text.
206  */
207 void
208 usage(char *name)
209 {
210 	int i;
211 
212 	for (i = 0; pcitool_usage_intr[i] != NULL; i++) {
213 		/*LINTED*/
214 		(void) printf(pcitool_usage_intr[i], name);
215 		(void) printf("\n");
216 	}
217 }
218 
219 #endif	/* _PCITOOL_USAGE_TEXT_H */
220