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