xref: /onnv-gate/usr/src/uts/sun4/sys/memnode.h (revision 4769:291956cbfc21)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*4769Sdp78419  * Common Development and Distribution License (the "License").
6*4769Sdp78419  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*4769Sdp78419  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_MEMNODE_H
270Sstevel@tonic-gate #define	_SYS_MEMNODE_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef	_KERNEL
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #include <sys/lgrp.h>
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * This file defines the mappings between physical addresses and memory
410Sstevel@tonic-gate  * nodes. Memory nodes are defined so that the low-order bits are the
420Sstevel@tonic-gate  * memory slice ID and the high-order bits are the SSM nodeid.
430Sstevel@tonic-gate  */
440Sstevel@tonic-gate 
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate  * The MAX_MEM_NODES constant is the maximum number of memory nodes for the
470Sstevel@tonic-gate  * unix binary and is used to help size static data structures.  The
480Sstevel@tonic-gate  * max_mem_nodes variable is the maximum number of memory nodes for the
490Sstevel@tonic-gate  * running platform and may be smaller than MAX_MEM_NODES since the platform
500Sstevel@tonic-gate  * may not need to use all of them.
510Sstevel@tonic-gate  *
520Sstevel@tonic-gate  * The default value of MAX_MEM_NODES is 4 to create enough memory nodes for
530Sstevel@tonic-gate  * Chalupa and max_mem_nodes is set to 1 by default since the generic sun4u
540Sstevel@tonic-gate  * unix binary mostly includes platforms only needing one memory node.
550Sstevel@tonic-gate  * For platforms requiring more than one memory node, max_mem_nodes is set to
560Sstevel@tonic-gate  * a bigger value in the lgroup platform initialization routines which are
570Sstevel@tonic-gate  * called before the memory nodes are initialized.  Some platforms like
580Sstevel@tonic-gate  * Serengeti and Starcat simply define MAX_MEM_NODES to be their respective
590Sstevel@tonic-gate  * maximum memory nodes at compile time, since they have their own unix binary
600Sstevel@tonic-gate  * and don't share one with any other platform like Enchilada and Chalupa do.
610Sstevel@tonic-gate  *
620Sstevel@tonic-gate  * For machines that don't support DR, they can set max_mem_nodes to the actual
630Sstevel@tonic-gate  * number of memory nodes in the running system instead of the maximum.  The
640Sstevel@tonic-gate  * platform controls the mapping of lgroup platform handles and PFNs to memory
650Sstevel@tonic-gate  * nodes, so the platform can always make everything work.
660Sstevel@tonic-gate  */
670Sstevel@tonic-gate 
68*4769Sdp78419 #ifndef MAX_MEM_NODES
690Sstevel@tonic-gate #define	MAX_MEM_NODES	(4)
700Sstevel@tonic-gate #endif	/* MAX_MEM_NODES */
710Sstevel@tonic-gate 
720Sstevel@tonic-gate #define	PFN_2_MEM_NODE(pfn)			\
730Sstevel@tonic-gate 	((max_mem_nodes > 1) ? plat_pfn_to_mem_node(pfn) : 0)
740Sstevel@tonic-gate 
750Sstevel@tonic-gate #define	MEM_NODE_2_LGRPHAND(mnode)		\
760Sstevel@tonic-gate 	((max_mem_nodes > 1) ? plat_mem_node_to_lgrphand(mnode) : \
770Sstevel@tonic-gate 	    LGRP_DEFAULT_HANDLE)
780Sstevel@tonic-gate 
790Sstevel@tonic-gate /*
800Sstevel@tonic-gate  * Platmod hooks
810Sstevel@tonic-gate  */
820Sstevel@tonic-gate 
830Sstevel@tonic-gate extern int plat_pfn_to_mem_node(pfn_t);
840Sstevel@tonic-gate extern int plat_lgrphand_to_mem_node(lgrp_handle_t);
850Sstevel@tonic-gate extern void plat_assign_lgrphand_to_mem_node(lgrp_handle_t, int);
860Sstevel@tonic-gate extern lgrp_handle_t plat_mem_node_to_lgrphand(int);
870Sstevel@tonic-gate extern void plat_slice_add(pfn_t, pfn_t);
880Sstevel@tonic-gate extern void plat_slice_del(pfn_t, pfn_t);
89*4769Sdp78419 extern void plat_mem_node_intersect_range(pfn_t, pgcnt_t, int, pgcnt_t *);
900Sstevel@tonic-gate 
910Sstevel@tonic-gate #pragma	weak plat_pfn_to_mem_node
920Sstevel@tonic-gate #pragma	weak plat_lgrphand_to_mem_node
930Sstevel@tonic-gate #pragma	weak plat_mem_node_to_lgrphand
940Sstevel@tonic-gate #pragma	weak plat_slice_add
950Sstevel@tonic-gate #pragma	weak plat_slice_del
96*4769Sdp78419 #pragma weak plat_mem_node_intersect_range
970Sstevel@tonic-gate 
980Sstevel@tonic-gate struct	mem_node_conf {
990Sstevel@tonic-gate 	int	exists;		/* only try if set, list may still be empty */
1000Sstevel@tonic-gate 	pfn_t	physbase;	/* lowest PFN in this memnode */
1010Sstevel@tonic-gate 	pfn_t	physmax;	/* highest PFN in this memnode */
1020Sstevel@tonic-gate };
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate struct memlist;
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate extern void startup_build_mem_nodes(u_longlong_t *, size_t);
1070Sstevel@tonic-gate extern void mem_node_add_slice(pfn_t, pfn_t);
1080Sstevel@tonic-gate extern void mem_node_pre_del_slice(pfn_t, pfn_t);
1090Sstevel@tonic-gate extern void mem_node_post_del_slice(pfn_t, pfn_t, int);
1100Sstevel@tonic-gate extern int mem_node_alloc(void);
1110Sstevel@tonic-gate extern pgcnt_t mem_node_memlist_pages(int, struct memlist *);
112*4769Sdp78419 extern void mem_node_add_slice(pfn_t start, pfn_t end);
113*4769Sdp78419 extern void mem_node_max_range(pfn_t *, pfn_t *);
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate extern struct mem_node_conf	mem_node_config[];
1160Sstevel@tonic-gate extern uint64_t			mem_node_physalign;
1170Sstevel@tonic-gate extern int			mem_node_pfn_shift;
1180Sstevel@tonic-gate extern int			max_mem_nodes;
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate #endif	/* _KERNEL */
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate #ifdef	__cplusplus
1230Sstevel@tonic-gate }
1240Sstevel@tonic-gate #endif
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate #endif	/* _SYS_MEMNODE_H */
127