xref: /illumos-gate/usr/src/uts/sun4u/sys/mc.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_MC_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_MC_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate /*
37*7c478bd9Sstevel@tonic-gate  * Interface of Memory Controller driver
38*7c478bd9Sstevel@tonic-gate  *
39*7c478bd9Sstevel@tonic-gate  * Logical view: memory -> segment -> bank -> device group -> device
40*7c478bd9Sstevel@tonic-gate  * physical view: mc -> device group -> device
41*7c478bd9Sstevel@tonic-gate  *
42*7c478bd9Sstevel@tonic-gate  * MCIOC_MEM, MCIOC_SEG, MCIOC_CTRLCONF, MCIOC_CONTROL are
43*7c478bd9Sstevel@tonic-gate  * associated with various length struct. If given number is less than the
44*7c478bd9Sstevel@tonic-gate  * number in kernel, kernel will update the number and return EINVAL so that
45*7c478bd9Sstevel@tonic-gate  * user could allocate enough space for the struct and fill the right number
46*7c478bd9Sstevel@tonic-gate  * of ids at the struct.
47*7c478bd9Sstevel@tonic-gate  *
48*7c478bd9Sstevel@tonic-gate  * All varaiable number ids will be paired, global and local. Global id is
49*7c478bd9Sstevel@tonic-gate  * unique in the same object list and local id is only unique to
50*7c478bd9Sstevel@tonic-gate  * its upper layer. For instance, one memory module group has N memory modules.
51*7c478bd9Sstevel@tonic-gate  * local ids of this memory module group is from 0 to N - 1, but global id
52*7c478bd9Sstevel@tonic-gate  * is unique in all memory modules. So global id will be the key in the list
53*7c478bd9Sstevel@tonic-gate  * and pass it to driver to search. Local id will be returned to user
54*7c478bd9Sstevel@tonic-gate  * application via ioctl.
55*7c478bd9Sstevel@tonic-gate  */
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate #define	MCIOC		('M' << 8)
58*7c478bd9Sstevel@tonic-gate #define	MCIOC_MEMCONF	(MCIOC|8)
59*7c478bd9Sstevel@tonic-gate #define	MCIOC_MEM	(MCIOC|9)
60*7c478bd9Sstevel@tonic-gate #define	MCIOC_SEG	(MCIOC|10)
61*7c478bd9Sstevel@tonic-gate #define	MCIOC_BANK	(MCIOC|11)
62*7c478bd9Sstevel@tonic-gate #define	MCIOC_DEVGRP	(MCIOC|12)
63*7c478bd9Sstevel@tonic-gate #define	MCIOC_CTRLCONF	(MCIOC|13)
64*7c478bd9Sstevel@tonic-gate #define	MCIOC_CONTROL	(MCIOC|14)
65*7c478bd9Sstevel@tonic-gate #define	MCIOC_ECFLUSH	(MCIOC|15)
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate /*
68*7c478bd9Sstevel@tonic-gate  * libdevinfo property name for exporting the Memory Address
69*7c478bd9Sstevel@tonic-gate  * Decode Registers for each Logical bank. An array of [NBANK]
70*7c478bd9Sstevel@tonic-gate  * uint64_t's is created for each memory-controller node.
71*7c478bd9Sstevel@tonic-gate  */
72*7c478bd9Sstevel@tonic-gate #define	MEM_CFG_PROP_NAME	"logical-bank-ma-regs"
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate struct mc_ids {
75*7c478bd9Sstevel@tonic-gate 	int	globalid;
76*7c478bd9Sstevel@tonic-gate 	int	localid;
77*7c478bd9Sstevel@tonic-gate };
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate /*
80*7c478bd9Sstevel@tonic-gate  * Enabled memory controller is able to get memory-layout property, and
81*7c478bd9Sstevel@tonic-gate  * it could be with or without memory.
82*7c478bd9Sstevel@tonic-gate  */
83*7c478bd9Sstevel@tonic-gate struct mc_memconf {
84*7c478bd9Sstevel@tonic-gate 	int nmcs;	/* The number of enabled memory controllers */
85*7c478bd9Sstevel@tonic-gate 	int nsegments;	/* The number of memory segments */
86*7c478bd9Sstevel@tonic-gate 	int nbanks;	/* The max. number of banks per segment */
87*7c478bd9Sstevel@tonic-gate 	int ndevgrps;	/* The max. number of device groups per mc */
88*7c478bd9Sstevel@tonic-gate 	int ndevs;	/* The max. number of devices per device group */
89*7c478bd9Sstevel@tonic-gate 	int len_dev;	/* The length of device label */
90*7c478bd9Sstevel@tonic-gate 	int xfer_size;	/* Data transfer size in CPU cache line */
91*7c478bd9Sstevel@tonic-gate };
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate struct mc_memory {
94*7c478bd9Sstevel@tonic-gate 	uint64_t size;		/* size of physical memory */
95*7c478bd9Sstevel@tonic-gate 	int nsegments;		/* The number of memory segments */
96*7c478bd9Sstevel@tonic-gate 	struct mc_ids segmentids[1]; /* segment ids for next iteration */
97*7c478bd9Sstevel@tonic-gate };
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate struct mc_segment {
100*7c478bd9Sstevel@tonic-gate 	int id;			/* unique segment id */
101*7c478bd9Sstevel@tonic-gate 	int ifactor;		/* interleave factor for this segment */
102*7c478bd9Sstevel@tonic-gate 	uint64_t base;		/* starting physical address */
103*7c478bd9Sstevel@tonic-gate 	uint64_t size;		/* in bytes */
104*7c478bd9Sstevel@tonic-gate 	int nbanks;		/* The number of banks at this segment */
105*7c478bd9Sstevel@tonic-gate 	struct mc_ids bankids[1]; /* logical bank ids for next iteration */
106*7c478bd9Sstevel@tonic-gate };
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate struct mc_bank {
109*7c478bd9Sstevel@tonic-gate 	int id;			/* unique id for logic bank */
110*7c478bd9Sstevel@tonic-gate 	struct mc_ids devgrpid;	/* Only one device group id per logical bank */
111*7c478bd9Sstevel@tonic-gate 	uint64_t mask;		/* If (Physic Address & MASK) == MATCH, */
112*7c478bd9Sstevel@tonic-gate 	uint64_t match;		/* Physic Address is located at this bank. */
113*7c478bd9Sstevel@tonic-gate 	uint64_t size;		/* memory size per logical bank */
114*7c478bd9Sstevel@tonic-gate };
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate struct mc_ctrlconf {
117*7c478bd9Sstevel@tonic-gate 	int nmcs;		/* The number of enabled memory controllers */
118*7c478bd9Sstevel@tonic-gate 	struct mc_ids mcids[1];	/* mc ids for next iteration */
119*7c478bd9Sstevel@tonic-gate };
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate struct mc_control {
122*7c478bd9Sstevel@tonic-gate 	int id;			/* unique id for memory controllers */
123*7c478bd9Sstevel@tonic-gate 	int ndevgrps;		/* The number of device groups on this mc */
124*7c478bd9Sstevel@tonic-gate 	struct mc_ids devgrpids[1]; /* device group ids for next iteration */
125*7c478bd9Sstevel@tonic-gate };
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate struct mc_devgrp {
128*7c478bd9Sstevel@tonic-gate 	int id;		/* unique id for device groups */
129*7c478bd9Sstevel@tonic-gate 	int ndevices;	/* The number of available devices on this dev group */
130*7c478bd9Sstevel@tonic-gate 	uint64_t size;	/* memory size per physical dimm group */
131*7c478bd9Sstevel@tonic-gate };
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
134*7c478bd9Sstevel@tonic-gate }
135*7c478bd9Sstevel@tonic-gate #endif
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_MC_H */
138