xref: /titanic_52/usr/src/uts/sun4/sys/memnode.h (revision 038dc6b3d39a14038605fbb3fc6a9bb76dd27fa8)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_MEMNODE_H
27 #define	_SYS_MEMNODE_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #ifdef	_KERNEL
36 
37 #include <sys/lgrp.h>
38 
39 /*
40  * This file defines the mappings between physical addresses and memory
41  * nodes. Memory nodes are defined so that the low-order bits are the
42  * memory slice ID and the high-order bits are the SSM nodeid.
43  */
44 
45 /*
46  * The MAX_MEM_NODES constant is the maximum number of memory nodes for the
47  * unix binary and is used to help size static data structures.  The
48  * max_mem_nodes variable is the maximum number of memory nodes for the
49  * running platform and may be smaller than MAX_MEM_NODES since the platform
50  * may not need to use all of them.
51  *
52  * The default value of MAX_MEM_NODES is 4 to create enough memory nodes for
53  * Chalupa and max_mem_nodes is set to 1 by default since the generic sun4u
54  * unix binary mostly includes platforms only needing one memory node.
55  * For platforms requiring more than one memory node, max_mem_nodes is set to
56  * a bigger value in the lgroup platform initialization routines which are
57  * called before the memory nodes are initialized.  Some platforms like
58  * Serengeti and Starcat simply define MAX_MEM_NODES to be their respective
59  * maximum memory nodes at compile time, since they have their own unix binary
60  * and don't share one with any other platform like Enchilada and Chalupa do.
61  *
62  * For machines that don't support DR, they can set max_mem_nodes to the actual
63  * number of memory nodes in the running system instead of the maximum.  The
64  * platform controls the mapping of lgroup platform handles and PFNs to memory
65  * nodes, so the platform can always make everything work.
66  */
67 
68 #ifndef MAX_MEM_NODES
69 #define	MAX_MEM_NODES	(4)
70 #endif	/* MAX_MEM_NODES */
71 
72 #define	PFN_2_MEM_NODE(pfn)			\
73 	((max_mem_nodes > 1) ? plat_pfn_to_mem_node(pfn) : 0)
74 
75 #define	MEM_NODE_2_LGRPHAND(mnode)		\
76 	((max_mem_nodes > 1) ? plat_mem_node_to_lgrphand(mnode) : \
77 	    LGRP_DEFAULT_HANDLE)
78 
79 /*
80  * Platmod hooks
81  */
82 
83 extern int plat_pfn_to_mem_node(pfn_t);
84 extern int plat_lgrphand_to_mem_node(lgrp_handle_t);
85 extern void plat_assign_lgrphand_to_mem_node(lgrp_handle_t, int);
86 extern lgrp_handle_t plat_mem_node_to_lgrphand(int);
87 extern void plat_slice_add(pfn_t, pfn_t);
88 extern void plat_slice_del(pfn_t, pfn_t);
89 extern void plat_mem_node_intersect_range(pfn_t, pgcnt_t, int, pgcnt_t *);
90 
91 #pragma	weak plat_pfn_to_mem_node
92 #pragma	weak plat_lgrphand_to_mem_node
93 #pragma	weak plat_mem_node_to_lgrphand
94 #pragma	weak plat_slice_add
95 #pragma	weak plat_slice_del
96 #pragma weak plat_mem_node_intersect_range
97 
98 struct	mem_node_conf {
99 	int	exists;		/* only try if set, list may still be empty */
100 	pfn_t	physbase;	/* lowest PFN in this memnode */
101 	pfn_t	physmax;	/* highest PFN in this memnode */
102 };
103 
104 struct memlist;
105 
106 extern void startup_build_mem_nodes(u_longlong_t *, size_t);
107 extern void mem_node_add_slice(pfn_t, pfn_t);
108 extern void mem_node_pre_del_slice(pfn_t, pfn_t);
109 extern void mem_node_post_del_slice(pfn_t, pfn_t, int);
110 extern int mem_node_alloc(void);
111 extern pgcnt_t mem_node_memlist_pages(int, struct memlist *);
112 extern void mem_node_add_slice(pfn_t start, pfn_t end);
113 extern void mem_node_max_range(pfn_t *, pfn_t *);
114 
115 extern struct mem_node_conf	mem_node_config[];
116 extern uint64_t			mem_node_physalign;
117 extern int			mem_node_pfn_shift;
118 extern int			max_mem_nodes;
119 
120 #endif	/* _KERNEL */
121 
122 #ifdef	__cplusplus
123 }
124 #endif
125 
126 #endif	/* _SYS_MEMNODE_H */
127