xref: /onnv-gate/usr/src/uts/sun4/sys/memnode.h (revision 5648)
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
54769Sdp78419  * Common Development and Distribution License (the "License").
64769Sdp78419  * 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 /*
224769Sdp78419  * 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>
38*5648Ssetje #include <sys/memlist_plat.h>
390Sstevel@tonic-gate 
400Sstevel@tonic-gate /*
410Sstevel@tonic-gate  * This file defines the mappings between physical addresses and memory
420Sstevel@tonic-gate  * nodes. Memory nodes are defined so that the low-order bits are the
430Sstevel@tonic-gate  * memory slice ID and the high-order bits are the SSM nodeid.
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate 
460Sstevel@tonic-gate /*
470Sstevel@tonic-gate  * The MAX_MEM_NODES constant is the maximum number of memory nodes for the
480Sstevel@tonic-gate  * unix binary and is used to help size static data structures.  The
490Sstevel@tonic-gate  * max_mem_nodes variable is the maximum number of memory nodes for the
500Sstevel@tonic-gate  * running platform and may be smaller than MAX_MEM_NODES since the platform
510Sstevel@tonic-gate  * may not need to use all of them.
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * The default value of MAX_MEM_NODES is 4 to create enough memory nodes for
540Sstevel@tonic-gate  * Chalupa and max_mem_nodes is set to 1 by default since the generic sun4u
550Sstevel@tonic-gate  * unix binary mostly includes platforms only needing one memory node.
560Sstevel@tonic-gate  * For platforms requiring more than one memory node, max_mem_nodes is set to
570Sstevel@tonic-gate  * a bigger value in the lgroup platform initialization routines which are
580Sstevel@tonic-gate  * called before the memory nodes are initialized.  Some platforms like
590Sstevel@tonic-gate  * Serengeti and Starcat simply define MAX_MEM_NODES to be their respective
600Sstevel@tonic-gate  * maximum memory nodes at compile time, since they have their own unix binary
610Sstevel@tonic-gate  * and don't share one with any other platform like Enchilada and Chalupa do.
620Sstevel@tonic-gate  *
630Sstevel@tonic-gate  * For machines that don't support DR, they can set max_mem_nodes to the actual
640Sstevel@tonic-gate  * number of memory nodes in the running system instead of the maximum.  The
650Sstevel@tonic-gate  * platform controls the mapping of lgroup platform handles and PFNs to memory
660Sstevel@tonic-gate  * nodes, so the platform can always make everything work.
670Sstevel@tonic-gate  */
680Sstevel@tonic-gate 
694769Sdp78419 #ifndef MAX_MEM_NODES
700Sstevel@tonic-gate #define	MAX_MEM_NODES	(4)
710Sstevel@tonic-gate #endif	/* MAX_MEM_NODES */
720Sstevel@tonic-gate 
730Sstevel@tonic-gate #define	PFN_2_MEM_NODE(pfn)			\
740Sstevel@tonic-gate 	((max_mem_nodes > 1) ? plat_pfn_to_mem_node(pfn) : 0)
750Sstevel@tonic-gate 
760Sstevel@tonic-gate #define	MEM_NODE_2_LGRPHAND(mnode)		\
770Sstevel@tonic-gate 	((max_mem_nodes > 1) ? plat_mem_node_to_lgrphand(mnode) : \
780Sstevel@tonic-gate 	    LGRP_DEFAULT_HANDLE)
790Sstevel@tonic-gate 
800Sstevel@tonic-gate /*
810Sstevel@tonic-gate  * Platmod hooks
820Sstevel@tonic-gate  */
830Sstevel@tonic-gate 
840Sstevel@tonic-gate extern int plat_pfn_to_mem_node(pfn_t);
850Sstevel@tonic-gate extern int plat_lgrphand_to_mem_node(lgrp_handle_t);
860Sstevel@tonic-gate extern void plat_assign_lgrphand_to_mem_node(lgrp_handle_t, int);
870Sstevel@tonic-gate extern lgrp_handle_t plat_mem_node_to_lgrphand(int);
880Sstevel@tonic-gate extern void plat_slice_add(pfn_t, pfn_t);
890Sstevel@tonic-gate extern void plat_slice_del(pfn_t, pfn_t);
904769Sdp78419 extern void plat_mem_node_intersect_range(pfn_t, pgcnt_t, int, pgcnt_t *);
910Sstevel@tonic-gate 
920Sstevel@tonic-gate #pragma	weak plat_pfn_to_mem_node
930Sstevel@tonic-gate #pragma	weak plat_lgrphand_to_mem_node
940Sstevel@tonic-gate #pragma	weak plat_mem_node_to_lgrphand
950Sstevel@tonic-gate #pragma	weak plat_slice_add
960Sstevel@tonic-gate #pragma	weak plat_slice_del
974769Sdp78419 #pragma weak plat_mem_node_intersect_range
980Sstevel@tonic-gate 
990Sstevel@tonic-gate struct	mem_node_conf {
1000Sstevel@tonic-gate 	int	exists;		/* only try if set, list may still be empty */
1010Sstevel@tonic-gate 	pfn_t	physbase;	/* lowest PFN in this memnode */
1020Sstevel@tonic-gate 	pfn_t	physmax;	/* highest PFN in this memnode */
1030Sstevel@tonic-gate };
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate struct memlist;
1060Sstevel@tonic-gate 
107*5648Ssetje extern void startup_build_mem_nodes(prom_memlist_t *, size_t);
1080Sstevel@tonic-gate extern void mem_node_add_slice(pfn_t, pfn_t);
1090Sstevel@tonic-gate extern void mem_node_pre_del_slice(pfn_t, pfn_t);
1100Sstevel@tonic-gate extern void mem_node_post_del_slice(pfn_t, pfn_t, int);
1110Sstevel@tonic-gate extern int mem_node_alloc(void);
1120Sstevel@tonic-gate extern pgcnt_t mem_node_memlist_pages(int, struct memlist *);
1134769Sdp78419 extern void mem_node_add_slice(pfn_t start, pfn_t end);
1144769Sdp78419 extern void mem_node_max_range(pfn_t *, pfn_t *);
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate extern struct mem_node_conf	mem_node_config[];
1170Sstevel@tonic-gate extern uint64_t			mem_node_physalign;
1180Sstevel@tonic-gate extern int			mem_node_pfn_shift;
1190Sstevel@tonic-gate extern int			max_mem_nodes;
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate #endif	/* _KERNEL */
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate #ifdef	__cplusplus
1240Sstevel@tonic-gate }
1250Sstevel@tonic-gate #endif
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate #endif	/* _SYS_MEMNODE_H */
128