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 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include <strings.h>
28
29 #include "hb_rcid.h"
30
31 /* A list of physical root complexes of the SUNW,Sun-Fire-T200 platform */
32 prc_t t200_prcs[] = {
33 /* physical id, bus address */
34 { 0, 0x780 },
35 { 1, 0x7c0 }
36 };
37
38 /* A list of physical root complexes of the SUNW,T5140 platform */
39 prc_t t5140_prcs[] = {
40 /* physical id, bus address */
41 { 0, 0x400 },
42 { 1, 0x500 }
43 };
44
45
46 pprc_t plat_prcids[] = {
47 /*
48 * platforms that have the same map with T200
49 */
50 { "SUNW,Sun-Fire-T200",
51 sizeof (t200_prcs) / sizeof (prc_t),
52 t200_prcs },
53 { "SUNW,Sun-Fire-T1000",
54 sizeof (t200_prcs) / sizeof (prc_t),
55 t200_prcs },
56 { "SUNW,SPARC-Enterprise-T2000",
57 sizeof (t200_prcs) / sizeof (prc_t),
58 t200_prcs },
59 { "SUNW,SPARC-Enterprise-T1000",
60 sizeof (t200_prcs) / sizeof (prc_t),
61 t200_prcs },
62 { "SUNW,Netra-CP3060",
63 sizeof (t200_prcs) / sizeof (prc_t),
64 t200_prcs },
65 { "SUNW,Netra-T2000",
66 sizeof (t200_prcs) / sizeof (prc_t),
67 t200_prcs },
68 { "SUNW,Sun-Blade-T6300",
69 sizeof (t200_prcs) / sizeof (prc_t),
70 t200_prcs },
71
72 /*
73 * platforms that have the same map with T5140
74 */
75 { "SUNW,T5140",
76 sizeof (t5140_prcs) / sizeof (prc_t),
77 t5140_prcs },
78 { "SUNW,T5240",
79 sizeof (t5140_prcs) / sizeof (prc_t),
80 t5140_prcs },
81 { "SUNW,Netra-T5440",
82 sizeof (t5140_prcs) / sizeof (prc_t),
83 t5140_prcs },
84 { "SUNW,Sun-Blade-T6340",
85 sizeof (t5140_prcs) / sizeof (prc_t),
86 t5140_prcs },
87 { "SUNW,USBRDT-5240",
88 sizeof (t5140_prcs) / sizeof (prc_t),
89 t5140_prcs }
90 };
91
92 pprcs_t prcids = {
93 sizeof (plat_prcids) / sizeof (pprc_t),
94 plat_prcids
95 };
96
97 /*
98 * hb_find_rc_pid()
99 * Description:
100 * Return the physical id (non-negative) of a root complex given the
101 * plaform name and its bus address.
102 */
103 int
hb_find_rc_pid(char * platform,uint64_t ba)104 hb_find_rc_pid(char *platform, uint64_t ba)
105 {
106 int rcid = -1;
107 int p, i;
108
109 for (p = 0; p < prcids.nplats; p++) {
110 if (strcmp(prcids.plats[p].platform, platform) != 0)
111 continue;
112 for (i = 0; i < prcids.plats[p].nrcs; i++) {
113 prc_t pciexrc;
114 pciexrc = prcids.plats[p].rcs[i];
115 if (pciexrc.ba == ba) {
116 rcid = pciexrc.id;
117 break;
118 }
119 }
120 break;
121 }
122 return (rcid);
123 }
124