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