xref: /titanic_51/usr/src/lib/fm/topo/modules/sun4v/platform-mem/mem_mdesc.h (revision b69a86957bad202e0d4cd49e4ceb7fea54a83270)
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 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _MEM_MDESC_H
28 #define	_MEM_MDESC_H
29 
30 #include <fm/topo_mod.h>
31 #include <sys/fm/ldom.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define	MEM_DIMM_MAX	8		/* max FB DIMM depth */
38 
39 #ifndef	MIN
40 #define	MIN(x, y) ((x) < (y) ? (x) : (y))
41 #endif
42 
43 #ifndef	MAX
44 #define	MAX(x, y) ((x) > (y) ? (x) : (y))
45 #endif
46 
47 typedef struct mem_dimm_map {
48 	struct mem_dimm_map *dm_next;	/* The next DIMM map */
49 	char *dm_label;			/* The UNUM for this DIMM */
50 	char *dm_serid; 		/* Cached serial number */
51 	char *dm_part;			/* DIMM part number */
52 	uint64_t dm_drgen;		/* DR gen count for cached S/N */
53 } mem_dimm_map_t;
54 
55 typedef	struct mem_dimm_list {
56 	struct mem_dimm_list *dl_next;
57 	mem_dimm_map_t *dl_dimm;
58 } mem_dimm_list_t;
59 
60 typedef struct mem_bank_map {
61 	struct mem_bank_map *bm_next;	/* the next bank map overall */
62 	struct mem_bank_map *bm_grp;	/* next bank map in group */
63 	uint64_t	bm_mask;
64 	uint64_t	bm_match;
65 	uint16_t	bm_shift;	/* dimms-per-reference shift */
66 	mem_dimm_list_t *bm_dlist;
67 } mem_bank_map_t;
68 
69 typedef struct mem_grp {
70 	struct mem_grp *mg_next;
71 	size_t		mg_size;
72 	mem_bank_map_t *mg_bank;
73 } mem_grp_t;
74 
75 typedef struct mem_seg_map {
76 	struct mem_seg_map *sm_next;	/* the next segment map */
77 	uint64_t	sm_base;	/* base address for this segment */
78 	uint64_t	sm_size;	/* size for this segment */
79 	mem_grp_t	*sm_grp;
80 } mem_seg_map_t;
81 
82 typedef struct md_mem_info {
83 	mem_dimm_map_t *mem_dm;		/* List supported DIMMs */
84 /*	uint64_t mem_memconfig;		   HV memory-configuration-id# */
85 	mem_seg_map_t *mem_seg;		/* list of defined segments */
86 	mem_bank_map_t *mem_bank;
87 	mem_grp_t *mem_group;		/* groups of banks for a segment */
88 } md_mem_info_t;
89 
90 extern int mem_mdesc_init(topo_mod_t *, md_mem_info_t *);
91 extern void mem_mdesc_fini(topo_mod_t *, md_mem_info_t *);
92 extern mem_dimm_map_t *mem_get_dimm_by_sn(char *, md_mem_info_t *);
93 extern void *mem_alloc(size_t);
94 extern void mem_free(void *, size_t);
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif /* _MEM_MDESC_H */
101