xref: /titanic_52/usr/src/cmd/pcitool/pcitool_usage.c (revision b7de0f897aaee33aba2a0cc1d3ab98aa450a4da9)
1d5ace945SErwin T Tsaur /*
2d5ace945SErwin T Tsaur  * CDDL HEADER START
3d5ace945SErwin T Tsaur  *
4d5ace945SErwin T Tsaur  * The contents of this file are subject to the terms of the
5d5ace945SErwin T Tsaur  * Common Development and Distribution License (the "License").
6d5ace945SErwin T Tsaur  * You may not use this file except in compliance with the License.
7d5ace945SErwin T Tsaur  *
8d5ace945SErwin T Tsaur  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9d5ace945SErwin T Tsaur  * or http://www.opensolaris.org/os/licensing.
10d5ace945SErwin T Tsaur  * See the License for the specific language governing permissions
11d5ace945SErwin T Tsaur  * and limitations under the License.
12d5ace945SErwin T Tsaur  *
13d5ace945SErwin T Tsaur  * When distributing Covered Code, include this CDDL HEADER in each
14d5ace945SErwin T Tsaur  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15d5ace945SErwin T Tsaur  * If applicable, add the following below this CDDL HEADER, with the
16d5ace945SErwin T Tsaur  * fields enclosed by brackets "[]" replaced with your own identifying
17d5ace945SErwin T Tsaur  * information: Portions Copyright [yyyy] [name of copyright owner]
18d5ace945SErwin T Tsaur  *
19d5ace945SErwin T Tsaur  * CDDL HEADER END
20d5ace945SErwin T Tsaur  */
21d5ace945SErwin T Tsaur /*
225cd376e8SJimmy Vetayases  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23d5ace945SErwin T Tsaur  */
24d5ace945SErwin T Tsaur 
25d5ace945SErwin T Tsaur #ifndef	_PCITOOL_USAGE_TEXT_H
26d5ace945SErwin T Tsaur #define	_PCITOOL_USAGE_TEXT_H
27d5ace945SErwin T Tsaur 
28d5ace945SErwin T Tsaur #include <stdio.h>
29d5ace945SErwin T Tsaur 
30d5ace945SErwin T Tsaur static char *pcitool_usage_reg[] = {
31d5ace945SErwin T Tsaur "Register peek/poke mode:",
32d5ace945SErwin T Tsaur " %s <PCI nexus node>",
33d5ace945SErwin T Tsaur "  [   -n bank=<register bank>",
34d5ace945SErwin T Tsaur "         where register bank is 0 for mapped jbus space and 1 for pcie space",
35d5ace945SErwin T Tsaur "         (only on applicable platforms)",
36d5ace945SErwin T Tsaur "",
37d5ace945SErwin T Tsaur "      -n base=<base address>",
38d5ace945SErwin T Tsaur "         where base address is a physical base address of a register bank",
39d5ace945SErwin T Tsaur "         (only on applicable platforms (e.g. sun4v) where bank info is "
40d5ace945SErwin T Tsaur 	"unavailable)",
41d5ace945SErwin T Tsaur "",
42d5ace945SErwin T Tsaur "      -d bus=<bus>,dev=<dev>,func=<func>,bank=<register bank>",
43d5ace945SErwin T Tsaur "      -d bdf=<bus>.<dev>.<func>,bank=<register bank>",
44d5ace945SErwin T Tsaur "",
45d5ace945SErwin T Tsaur "      -d bus=<bus>,dev=<dev>,func=<func> | bdf=<bus>.<dev>.<func> ,",
46d5ace945SErwin T Tsaur "	  [ config | bar0 | bar1 | bar2 | bar3 | bar4 | bar5 | rom ]",
47d5ace945SErwin T Tsaur "	  (spaces added for clarity but are not allowed in the command)",
48d5ace945SErwin T Tsaur "",
49d5ace945SErwin T Tsaur "  -n and -d options may also include:",
50d5ace945SErwin T Tsaur "",
51d5ace945SErwin T Tsaur "  [ -w <value to write> ] [ -r ]",
52d5ace945SErwin T Tsaur "  [ -o <offset> ]",
53d5ace945SErwin T Tsaur "  [ -s 1 | 2 | 4 | 8 ]",
54d5ace945SErwin T Tsaur "  [ -e b | l ]",
55d5ace945SErwin T Tsaur "  [ -l ]",
56d5ace945SErwin T Tsaur "  [ -b <number bytes to dump> [ -c ] [ -x ] ]",
57d5ace945SErwin T Tsaur "  [ -v ]",
58d5ace945SErwin T Tsaur "  [ -q ]",
59d5ace945SErwin T Tsaur "",
60d5ace945SErwin T Tsaur "  -n may also include:",
61d5ace945SErwin T Tsaur "",
62d5ace945SErwin T Tsaur "  [ -y ]",
63d5ace945SErwin T Tsaur "",
64d5ace945SErwin T Tsaur "Probe mode:",
65d5ace945SErwin T Tsaur " %s [ <PCI nexus node> ] [ -a ] [ -p ] [ -v ] [ -q ]",
66d5ace945SErwin T Tsaur "",
67d5ace945SErwin T Tsaur " %s <PCI nexus node> [ -p [ bus=<bus>,dev=<dev>,func=<func> ] [ -v ] [ -q ]",
68d5ace945SErwin T Tsaur " %s <PCI nexus node> [ -p [ bdf=<bus>.<dev>.<func> ] [ -v ] [-q ]",
69d5ace945SErwin T Tsaur "",
70d5ace945SErwin T Tsaur "Probe mode",
71d5ace945SErwin T Tsaur "----------",
72d5ace945SErwin T Tsaur "",
73d5ace945SErwin T Tsaur "-p [ bus=<bus>,dev=<dev>,func=<func> | bdf=<bus>.<dev>.<func> ]",
74d5ace945SErwin T Tsaur "     Specify bus, device and/or function of devices to search for and dump.",
75d5ace945SErwin T Tsaur "",
76d5ace945SErwin T Tsaur "-a Probe all buses.  By default, pcitool checks the PCI nexus node's",
77d5ace945SErwin T Tsaur "bus-range property to restrict which buses are probed.  This option",
78d5ace945SErwin T Tsaur "cannot be combined with an explicit bus specification.",
79d5ace945SErwin T Tsaur "",
80d5ace945SErwin T Tsaur "If a PCI nexus node is specified, pcitool looks only for devices",
81d5ace945SErwin T Tsaur "under that node.  If no PCI nexus node is specified, pcitool looks",
82d5ace945SErwin T Tsaur "for devices under all PCI nexus nodes.  PCI nexus nodes, which can",
83d5ace945SErwin T Tsaur "be used for other pcitool commands, are printed at the top of each tree.",
84d5ace945SErwin T Tsaur "",
85d5ace945SErwin T Tsaur "Non-verbose probe mode prints config register data as follows:",
86d5ace945SErwin T Tsaur "  aa bb c dddd eeee ffff gggg hh iiiiii jj kk ll mm",
87d5ace945SErwin T Tsaur "  where...",
88d5ace945SErwin T Tsaur "    a = pci bus number",
89d5ace945SErwin T Tsaur "    b = pci device number",
90d5ace945SErwin T Tsaur "    c = pci function number",
91d5ace945SErwin T Tsaur "    d = vendor ID",
92d5ace945SErwin T Tsaur "    e = device ID",
93d5ace945SErwin T Tsaur "    f = command register",
94d5ace945SErwin T Tsaur "    g = status register",
95d5ace945SErwin T Tsaur "    h = revision ID",
96d5ace945SErwin T Tsaur "    i = class code",
97d5ace945SErwin T Tsaur "    j = cache line size",
98d5ace945SErwin T Tsaur "    k = latency timer",
99d5ace945SErwin T Tsaur "    l = header type",
100d5ace945SErwin T Tsaur "    m = built in self test register (bist)",
101d5ace945SErwin T Tsaur "",
102d5ace945SErwin T Tsaur "Register peek/poke mode",
103d5ace945SErwin T Tsaur "-----------------------",
104d5ace945SErwin T Tsaur "",
105d5ace945SErwin T Tsaur "-n requests nexus node info.",
106d5ace945SErwin T Tsaur "   Specify desired nexus register using -o <register offset>",
107d5ace945SErwin T Tsaur "",
108d5ace945SErwin T Tsaur "-d requests device (leaf) node info.",
109d5ace945SErwin T Tsaur "   Specify bus, dev, function bits (from probe mode) as hex numbers.",
110d5ace945SErwin T Tsaur "   Bank is specified in one of the following ways:",
111d5ace945SErwin T Tsaur "     By value: 0 == config space, 1 == BAR0, 2 == BAR1, ..., 6 == BAR5, "
112d5ace945SErwin T Tsaur 	"7 == ROM",
113d5ace945SErwin T Tsaur "     By BAR (bus addr reg): config, bar0, bar1, bar2, bar3, bar4, bar5, rom",
114d5ace945SErwin T Tsaur "",
115d5ace945SErwin T Tsaur "Above peek/poke mode selections take the following options:",
116d5ace945SErwin T Tsaur "",
117d5ace945SErwin T Tsaur "-r for reading (default)",
118d5ace945SErwin T Tsaur "-w <value> for writing",
119d5ace945SErwin T Tsaur "-w <value> -r for writing a value followed by a readback",
120d5ace945SErwin T Tsaur "",
121d5ace945SErwin T Tsaur "-o <offset> to specify an offset within the requested address space",
122d5ace945SErwin T Tsaur "",
123d5ace945SErwin T Tsaur "-s <size specifier>: 1, 2, 4 or 8 bytes, default 4",
124d5ace945SErwin T Tsaur "   (8-byte transfers on supported platforms only)",
125d5ace945SErwin T Tsaur "",
126d5ace945SErwin T Tsaur "-e <endian specifier>: b or l (ell), default is l for little endian>",
127d5ace945SErwin T Tsaur "",
128d5ace945SErwin T Tsaur "-l to do repetitious accesses to/from the same location(s)",
129d5ace945SErwin T Tsaur "",
130d5ace945SErwin T Tsaur "-b <number of bytes to dump> [ -c ] to get a formatted multiple register dump",
131d5ace945SErwin T Tsaur "   starting at the offset given.  Hex bytes are always dumped.",
132d5ace945SErwin T Tsaur "   -c dumps characters as well.  "
133d5ace945SErwin T Tsaur 	"Non-printable characters are dumped as \"@\".",
134d5ace945SErwin T Tsaur "   -x keeps going on errors, and prints err characters as X",
135d5ace945SErwin T Tsaur "",
136d5ace945SErwin T Tsaur "Above nexus peek/poke mode selections take the following additional option:",
137d5ace945SErwin T Tsaur "",
138d5ace945SErwin T Tsaur "-y to confirm a base_addr without being prompted interactively",
139d5ace945SErwin T Tsaur "",
140d5ace945SErwin T Tsaur "NOTE: Some platforms (i.e. SPARC) return peek/poke errors as failed ioctls;",
141d5ace945SErwin T Tsaur "    Other platforms (i.e. X86) return peek/poke errors as FF values.",
142d5ace945SErwin T Tsaur "",
143d5ace945SErwin T Tsaur "All numeric values are in HEX",
144d5ace945SErwin T Tsaur NULL
145d5ace945SErwin T Tsaur };
146d5ace945SErwin T Tsaur 
147d5ace945SErwin T Tsaur static char *pcitool_usage_intr[] = {
148d5ace945SErwin T Tsaur "Usage:",
149d5ace945SErwin T Tsaur "Interrupt mode:",
150*b7de0f89Slipeng sang - Sun Microsystems - Beijing China " X86:",
151*b7de0f89Slipeng sang - Sun Microsystems - Beijing China " %s pci@<unit-address> -i <cpu#,ino#> | all",
1527ff178cdSJimmy Vetayases "       [ -r [ -c ] |  -w <cpu#> [ -g ] ] [ -v ] [ -q ]",
153*b7de0f89Slipeng sang - Sun Microsystems - Beijing China " SPARC:",
154*b7de0f89Slipeng sang - Sun Microsystems - Beijing China " %s pci@<unit-address> -i <ino#> | all",
155*b7de0f89Slipeng sang - Sun Microsystems - Beijing China "       [ -r [ -c ] |  -w <cpu#> [ -g ] ] [ -v ] [ -q ]",
156*b7de0f89Slipeng sang - Sun Microsystems - Beijing China " %s pci@<unit-address> -m <msi#> | all",
1577ff178cdSJimmy Vetayases "       [ -r [ -c ] |  -w <cpu#> [ -g ] ] [ -v ] [ -q ]",
158d5ace945SErwin T Tsaur "",
159d5ace945SErwin T Tsaur "where",
160d5ace945SErwin T Tsaur "",
16109b1eac2SEvan Yan "pci@<unit-address> is a node from /devices, with \"/devices\" stripped off.",
1627ff178cdSJimmy Vetayases "For example: /pci@0,0",
163d5ace945SErwin T Tsaur "",
164d5ace945SErwin T Tsaur "-v gives verbose output for all modes.",
165d5ace945SErwin T Tsaur "",
166d5ace945SErwin T Tsaur "-q suppresses error output (except for commandline parsing errors) for all "
167d5ace945SErwin T Tsaur 	"modes",
168d5ace945SErwin T Tsaur "   (Note that errno status is returned to the shell upon termination.)",
169d5ace945SErwin T Tsaur "",
170d5ace945SErwin T Tsaur "Online help mode:",
171d5ace945SErwin T Tsaur " %s -h",
172d5ace945SErwin T Tsaur "   Prints this message.",
173d5ace945SErwin T Tsaur "",
174d5ace945SErwin T Tsaur "Interrupt mode",
175d5ace945SErwin T Tsaur "--------------",
176d5ace945SErwin T Tsaur "",
1777ff178cdSJimmy Vetayases "-i <[cpu#],ino#> changes or retrieves current interrupts information of given",
1787ff178cdSJimmy Vetayases "   nexus and given INO. The special value of 'all' can be used to select all",
1797ff178cdSJimmy Vetayases "   INOs.",
180d5ace945SErwin T Tsaur "",
1817ff178cdSJimmy Vetayases "-m <[cpu#],msi#> changes or retrieves current interrupts information of given",
1827ff178cdSJimmy Vetayases "   nexus and given MSI/X. The special value of 'all' can be used to select",
1837ff178cdSJimmy Vetayases "   all MSI/Xs.",
1847ff178cdSJimmy Vetayases "",
1857ff178cdSJimmy Vetayases "   Note: [cpu#] is available on x86 platform, is to identify exclusive vector",
1867ff178cdSJimmy Vetayases "   with ino# at the same time. [cpu#] is not supported on SPARC platform.",
18709b1eac2SEvan Yan "",
18809b1eac2SEvan Yan "   Note: On x86 platforms, both INOs and MSI/Xs are mapped to the same",
18909b1eac2SEvan Yan "   interrupt vectors. Use -i option to retrieve and reroute any interrupt",
19009b1eac2SEvan Yan "   vectors (both INO and MSI/Xs).  So, -m option is not required on x86",
19109b1eac2SEvan Yan "   platforms. Hence it is not supported.",
19209b1eac2SEvan Yan "",
19309b1eac2SEvan Yan "   A specific INO or MSI/X must be selected if -w specified.",
19409b1eac2SEvan Yan "",
19509b1eac2SEvan Yan "-w <cpu#> [ -g ] to change an INO or MSI/X <->CPU binding.",
196d5ace945SErwin T Tsaur "",
197d5ace945SErwin T Tsaur "   Note: On certain platforms (e.g. X86), multiple MSI interrupts of a single",
198d5ace945SErwin T Tsaur "   function need to be moved together.  Use -g to do this.  -g works only on",
199d5ace945SErwin T Tsaur "   supported platforms and only for groups of MSI interrupts.  When -g is",
20009b1eac2SEvan Yan "   used, INO must be the lowest-numbered vector of the group.  (Use the mdb",
201d5ace945SErwin T Tsaur "   ::interrupts dcmd to discover groups of MSI vectors.)  The size of the",
202d5ace945SErwin T Tsaur "   group is determined internally.  (\"Groups\" of size 1 are accepted.)",
203d5ace945SErwin T Tsaur "",
20409b1eac2SEvan Yan "-r [ -c ] for displaying ino or msi <->CPU bindings of all selected INO/MSIs",
20509b1eac2SEvan Yan "   on a given nexus.  -c optionally dumps controller information.",
206d5ace945SErwin T Tsaur "",
20709b1eac2SEvan Yan "   All relevant enabled INO/MSI/Xs supporting non-nexus device interrupts",
20809b1eac2SEvan Yan "   will be printed.  For each printed INO/MSI/X, all supported devices and",
20909b1eac2SEvan Yan "   their CPU binding will be displayed.  On some platforms, INOs dedicated",
21009b1eac2SEvan Yan "   to the root nexus will be shown and marked with \"(Internal)\".",
211d5ace945SErwin T Tsaur "",
212d5ace945SErwin T Tsaur "When neither -r nor -w are specified, -r is the default.",
213d5ace945SErwin T Tsaur NULL
214d5ace945SErwin T Tsaur };
215d5ace945SErwin T Tsaur 
216d5ace945SErwin T Tsaur 
217d5ace945SErwin T Tsaur /*
218d5ace945SErwin T Tsaur  * Print usage statement.
219d5ace945SErwin T Tsaur  *
220d5ace945SErwin T Tsaur  * Text is too large for many print statements.
221d5ace945SErwin T Tsaur  *
222d5ace945SErwin T Tsaur  * Instead, loop through the array of strings in pcitool_usage_text.
223d5ace945SErwin T Tsaur  * Print program name when %s is in the text.
224d5ace945SErwin T Tsaur  */
225d5ace945SErwin T Tsaur void
226d5ace945SErwin T Tsaur usage(char *name)
227d5ace945SErwin T Tsaur {
228d5ace945SErwin T Tsaur 	int i;
229d5ace945SErwin T Tsaur 
230d5ace945SErwin T Tsaur 	for (i = 0; pcitool_usage_intr[i] != NULL; i++) {
231d5ace945SErwin T Tsaur 		/*LINTED*/
232d5ace945SErwin T Tsaur 		(void) printf(pcitool_usage_intr[i], name);
233d5ace945SErwin T Tsaur 		(void) printf("\n");
234d5ace945SErwin T Tsaur 	}
235d5ace945SErwin T Tsaur }
236d5ace945SErwin T Tsaur 
237d5ace945SErwin T Tsaur #endif	/* _PCITOOL_USAGE_TEXT_H */
238