xref: /onnv-gate/usr/src/uts/sun4/sys/memnode.h (revision 10106:b235491976d3)
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 /*
22*10106SJason.Beloro@Sun.COM  * Copyright 2009 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 #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #ifdef	_KERNEL
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/lgrp.h>
365648Ssetje #include <sys/memlist_plat.h>
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * This file defines the mappings between physical addresses and memory
400Sstevel@tonic-gate  * nodes. Memory nodes are defined so that the low-order bits are the
410Sstevel@tonic-gate  * memory slice ID and the high-order bits are the SSM nodeid.
420Sstevel@tonic-gate  */
430Sstevel@tonic-gate 
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate  * The MAX_MEM_NODES constant is the maximum number of memory nodes for the
460Sstevel@tonic-gate  * unix binary and is used to help size static data structures.  The
470Sstevel@tonic-gate  * max_mem_nodes variable is the maximum number of memory nodes for the
480Sstevel@tonic-gate  * running platform and may be smaller than MAX_MEM_NODES since the platform
490Sstevel@tonic-gate  * may not need to use all of them.
500Sstevel@tonic-gate  *
510Sstevel@tonic-gate  * The default value of MAX_MEM_NODES is 4 to create enough memory nodes for
520Sstevel@tonic-gate  * Chalupa and max_mem_nodes is set to 1 by default since the generic sun4u
530Sstevel@tonic-gate  * unix binary mostly includes platforms only needing one memory node.
540Sstevel@tonic-gate  * For platforms requiring more than one memory node, max_mem_nodes is set to
550Sstevel@tonic-gate  * a bigger value in the lgroup platform initialization routines which are
560Sstevel@tonic-gate  * called before the memory nodes are initialized.  Some platforms like
570Sstevel@tonic-gate  * Serengeti and Starcat simply define MAX_MEM_NODES to be their respective
580Sstevel@tonic-gate  * maximum memory nodes at compile time, since they have their own unix binary
590Sstevel@tonic-gate  * and don't share one with any other platform like Enchilada and Chalupa do.
600Sstevel@tonic-gate  *
610Sstevel@tonic-gate  * For machines that don't support DR, they can set max_mem_nodes to the actual
620Sstevel@tonic-gate  * number of memory nodes in the running system instead of the maximum.  The
630Sstevel@tonic-gate  * platform controls the mapping of lgroup platform handles and PFNs to memory
640Sstevel@tonic-gate  * nodes, so the platform can always make everything work.
650Sstevel@tonic-gate  */
660Sstevel@tonic-gate 
674769Sdp78419 #ifndef MAX_MEM_NODES
680Sstevel@tonic-gate #define	MAX_MEM_NODES	(4)
690Sstevel@tonic-gate #endif	/* MAX_MEM_NODES */
700Sstevel@tonic-gate 
710Sstevel@tonic-gate #define	PFN_2_MEM_NODE(pfn)			\
720Sstevel@tonic-gate 	((max_mem_nodes > 1) ? plat_pfn_to_mem_node(pfn) : 0)
730Sstevel@tonic-gate 
740Sstevel@tonic-gate #define	MEM_NODE_2_LGRPHAND(mnode)		\
750Sstevel@tonic-gate 	((max_mem_nodes > 1) ? plat_mem_node_to_lgrphand(mnode) : \
760Sstevel@tonic-gate 	    LGRP_DEFAULT_HANDLE)
770Sstevel@tonic-gate 
780Sstevel@tonic-gate /*
790Sstevel@tonic-gate  * Platmod hooks
800Sstevel@tonic-gate  */
810Sstevel@tonic-gate 
820Sstevel@tonic-gate extern int plat_pfn_to_mem_node(pfn_t);
830Sstevel@tonic-gate extern int plat_lgrphand_to_mem_node(lgrp_handle_t);
840Sstevel@tonic-gate extern void plat_assign_lgrphand_to_mem_node(lgrp_handle_t, int);
850Sstevel@tonic-gate extern lgrp_handle_t plat_mem_node_to_lgrphand(int);
860Sstevel@tonic-gate extern void plat_slice_add(pfn_t, pfn_t);
870Sstevel@tonic-gate extern void plat_slice_del(pfn_t, pfn_t);
884769Sdp78419 extern void plat_mem_node_intersect_range(pfn_t, pgcnt_t, int, pgcnt_t *);
890Sstevel@tonic-gate 
900Sstevel@tonic-gate #pragma	weak plat_pfn_to_mem_node
910Sstevel@tonic-gate #pragma	weak plat_lgrphand_to_mem_node
920Sstevel@tonic-gate #pragma	weak plat_mem_node_to_lgrphand
930Sstevel@tonic-gate #pragma	weak plat_slice_add
940Sstevel@tonic-gate #pragma	weak plat_slice_del
954769Sdp78419 #pragma weak plat_mem_node_intersect_range
960Sstevel@tonic-gate 
970Sstevel@tonic-gate struct	mem_node_conf {
980Sstevel@tonic-gate 	int	exists;		/* only try if set, list may still be empty */
990Sstevel@tonic-gate 	pfn_t	physbase;	/* lowest PFN in this memnode */
1000Sstevel@tonic-gate 	pfn_t	physmax;	/* highest PFN in this memnode */
1010Sstevel@tonic-gate };
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate struct memlist;
1040Sstevel@tonic-gate 
105*10106SJason.Beloro@Sun.COM /*
106*10106SJason.Beloro@Sun.COM  * Common layer calls the mem_node_*_range interfaces
107*10106SJason.Beloro@Sun.COM  * which in turn call the platmod hooks if they exist.
108*10106SJason.Beloro@Sun.COM  * The platmod layer then calls the mem_node_*slice interfaces.
109*10106SJason.Beloro@Sun.COM  */
1105648Ssetje extern void startup_build_mem_nodes(prom_memlist_t *, size_t);
1110Sstevel@tonic-gate extern void mem_node_add_slice(pfn_t, pfn_t);
112*10106SJason.Beloro@Sun.COM extern void mem_node_del_slice(pfn_t, pfn_t);
1130Sstevel@tonic-gate extern int mem_node_alloc(void);
1140Sstevel@tonic-gate extern pgcnt_t mem_node_memlist_pages(int, struct memlist *);
1154769Sdp78419 extern void mem_node_max_range(pfn_t *, pfn_t *);
116*10106SJason.Beloro@Sun.COM extern void mem_node_add_range(pfn_t, pfn_t);
117*10106SJason.Beloro@Sun.COM extern void mem_node_del_range(pfn_t, pfn_t);
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate extern struct mem_node_conf	mem_node_config[];
1200Sstevel@tonic-gate extern uint64_t			mem_node_physalign;
1210Sstevel@tonic-gate extern int			mem_node_pfn_shift;
1220Sstevel@tonic-gate extern int			max_mem_nodes;
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate #endif	/* _KERNEL */
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate #ifdef	__cplusplus
1270Sstevel@tonic-gate }
1280Sstevel@tonic-gate #endif
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate #endif	/* _SYS_MEMNODE_H */
131