xref: /titanic_51/usr/src/uts/i86pc/sys/memnode.h (revision 13bb89069ebe3cbce237b2708bda9946a2ff4607)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_MEMNODE_H
28 #define	_SYS_MEMNODE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #ifdef	_KERNEL
37 
38 #include <sys/lgrp.h>
39 
40 
41 /*
42  * This file defines the mappings between physical addresses and memory
43  * nodes. Memory nodes are defined so that the low-order bits are the
44  * memory slice ID and the high-order bits are the SSM nodeid.
45  */
46 
47 #ifndef	MAX_MEM_NODES
48 #define	MAX_MEM_NODES	(8)
49 #endif	/* MAX_MEM_NODES */
50 
51 #define	PFN_2_MEM_NODE(pfn)			\
52 	((max_mem_nodes > 1) ? plat_pfn_to_mem_node(pfn) : 0)
53 
54 #define	LGRPHAND_2_MEM_NODE(lgrp_plat_hand)	\
55 	((max_mem_nodes > 1) ? plat_lgrphand_to_mem_node(lgrp_plat_hand) : 0)
56 
57 #define	MEM_NODE_2_LGRPHAND(mnode)		\
58 	((max_mem_nodes > 1) ? plat_mem_node_to_lgrphand(mnode) : \
59 	    LGRP_DEFAULT_HANDLE)
60 
61 /*
62  * Platmod hooks
63  */
64 
65 extern int plat_pfn_to_mem_node(pfn_t);
66 extern int plat_lgrphand_to_mem_node(lgrp_handle_t);
67 extern void plat_assign_lgrphand_to_mem_node(lgrp_handle_t, int);
68 extern lgrp_handle_t plat_mem_node_to_lgrphand(int);
69 extern void plat_slice_add(pfn_t, pfn_t);
70 extern void plat_slice_del(pfn_t, pfn_t);
71 
72 #pragma	weak plat_pfn_to_mem_node
73 #pragma	weak plat_lgrphand_to_mem_node
74 #pragma	weak plat_mem_node_to_lgrphand
75 #pragma	weak plat_slice_add
76 #pragma	weak plat_slice_del
77 
78 struct	mem_node_conf {
79 	int	exists;		/* only try if set, list may still be empty */
80 	pfn_t	physbase;	/* lowest PFN in this memnode */
81 	pfn_t	physmax;	/* highest PFN in this memnode */
82 };
83 
84 struct memlist;
85 
86 extern void startup_build_mem_nodes(struct memlist *);
87 extern void mem_node_add_slice(pfn_t, pfn_t);
88 extern void mem_node_pre_del_slice(pfn_t, pfn_t);
89 extern void mem_node_post_del_slice(pfn_t, pfn_t, int);
90 extern int mem_node_alloc(void);
91 extern pgcnt_t mem_node_memlist_pages(int, struct memlist *);
92 
93 
94 extern struct mem_node_conf	mem_node_config[];
95 extern uint64_t			mem_node_physalign;
96 extern int			mem_node_pfn_shift;
97 extern int			max_mem_nodes;
98 
99 extern uint_t			lgrp_plat_node_cnt;
100 
101 #endif	/* _KERNEL */
102 
103 #ifdef	__cplusplus
104 }
105 #endif
106 
107 #endif	/* _SYS_MEMNODE_H */
108