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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _CHIP_H
27 #define	_CHIP_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <kstat.h>
32 #include <libnvpair.h>
33 #include <fm/libtopo.h>
34 #include <fm/topo_mod.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #define	CHIP_VERSION		TOPO_VERSION
41 
42 #define	CHIP_NODE_NAME	"chip"
43 #define	MCT_NODE_NAME	"memory-controller"
44 #define	CHAN_NODE_NAME	"dram-channel"
45 #define	CPU_NODE_NAME	"cpu"
46 #define	CS_NODE_NAME	"chip-select"
47 #define	DIMM_NODE_NAME	"dimm"
48 #define	RANK_NODE_NAME	"rank"
49 
50 #define	PGNAME(prefix)	(prefix##_NODE_NAME "-properties")
51 
52 /*
53  * chip-properties
54  */
55 #define	CHIP_VENDOR_ID	"vendor_id"
56 #define	CHIP_FAMILY	"family"
57 #define	CHIP_MODEL	"model"
58 #define	CHIP_STEPPING	"stepping"
59 
60 /*
61  * cpu-properties
62  */
63 #define	CPU_CHIP_ID	"chip_id"
64 #define	CPU_CORE_ID	"core_id"
65 #define	CPU_PKG_CORE_ID	"pkg_core_id"
66 #define	CPU_CLOG_ID	"clog_id"
67 
68 /*
69  * label property methods
70  */
71 #define	SIMPLE_DIMM_LBL		"simple_dimm_label"
72 #define	SIMPLE_DIMM_LBL_MP	"simple_dimm_label_mp"
73 #define	SEQ_DIMM_LBL		"seq_dimm_label"
74 #define	G4_DIMM_LBL		"g4_dimm_label"
75 #define	SIMPLE_CHIP_LBL		"simple_chip_label"
76 #define	G4_CHIP_LBL		"g4_chip_label"
77 #define	A4FPLUS_CHIP_LBL	"a4fplus_chip_label"
78 #define	SIMPLE_CS_LBL_MP	"simple_cs_label_mp"
79 
80 /*
81  * DIMM serial number property methods
82  */
83 #define	GET_DIMM_SERIAL		"get_dimm_serial"
84 
85 typedef struct chip {
86 	kstat_ctl_t *chip_kc;
87 	kstat_t **chip_cpustats;
88 	uint_t chip_ncpustats;
89 } chip_t;
90 
91 extern int simple_dimm_label(topo_mod_t *, tnode_t *, topo_version_t,
92     nvlist_t *, nvlist_t **);
93 
94 extern int simple_dimm_label_mp(topo_mod_t *, tnode_t *, topo_version_t,
95     nvlist_t *, nvlist_t **);
96 
97 extern int seq_dimm_label(topo_mod_t *, tnode_t *, topo_version_t,
98     nvlist_t *, nvlist_t **);
99 
100 extern int g4_dimm_label(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *,
101     nvlist_t **);
102 
103 extern int simple_chip_label(topo_mod_t *, tnode_t *, topo_version_t,
104     nvlist_t *, nvlist_t **);
105 
106 extern int g4_chip_label(topo_mod_t *, tnode_t *, topo_version_t,
107     nvlist_t *, nvlist_t **);
108 
109 extern int a4fplus_chip_label(topo_mod_t *, tnode_t *, topo_version_t,
110     nvlist_t *, nvlist_t **);
111 
112 extern int simple_cs_label_mp(topo_mod_t *, tnode_t *, topo_version_t,
113     nvlist_t *, nvlist_t **);
114 
115 extern int get_dimm_serial(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *,
116     nvlist_t **);
117 
118 /*
119  * Support functions of chip_subr.c
120  */
121 extern void whinge(topo_mod_t *, int *, const char *, ...);
122 extern int nvprop_add(topo_mod_t *, nvpair_t *, const char *, tnode_t *);
123 extern int add_kstat_strprop(topo_mod_t *, tnode_t *, kstat_t *,
124     const char *, const char *, const char **);
125 extern int add_kstat_longprop(topo_mod_t *, tnode_t *, kstat_t *,
126     const char *, const char *, int32_t *);
127 extern int add_kstat_longprops(topo_mod_t *, tnode_t *, kstat_t *,
128     const char *, int32_t *, ...);
129 extern int mkrsrc(topo_mod_t *, tnode_t *, const char *, int,
130     nvlist_t *, nvlist_t **);
131 extern nvlist_t *cpu_fmri_create(topo_mod_t *, uint32_t, char *, uint8_t);
132 extern nvlist_t *mem_fmri_create(topo_mod_t *, const char *);
133 extern int mem_asru_compute(topo_mod_t *, tnode_t *, topo_version_t,
134     nvlist_t *, nvlist_t **);
135 extern int rank_fmri_present(topo_mod_t *, tnode_t *, topo_version_t,
136     nvlist_t *, nvlist_t **);
137 extern int mem_asru_create(topo_mod_t *, nvlist_t *, nvlist_t **);
138 
139 /*
140  * Prototypes for chip_amd.c
141  */
142 extern void amd_mc_create(topo_mod_t *, tnode_t *, const char *, nvlist_t *,
143     int, int, int, int *);
144 
145 /*
146  * Prototypes for chip_intel.c
147  */
148 extern int mc_offchip_open(void);
149 extern int mc_offchip_create(topo_mod_t *, tnode_t *, const char *, nvlist_t *);
150 
151 extern char *get_fmtstr(topo_mod_t *, nvlist_t *);
152 extern int store_prop_val(topo_mod_t *, char *, char *, nvlist_t **out);
153 
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif /* _CHIP_H */
160