xref: /titanic_50/usr/src/uts/i86pc/sys/memnode.h (revision 8fd04b8338ed5093ec2d1e668fa620b7de44c177)
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 2009 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 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #ifdef	_KERNEL
34 
35 #include <sys/lgrp.h>
36 
37 
38 /*
39  * This file defines the mappings between physical addresses and memory
40  * nodes. Memory nodes are defined so that the low-order bits are the
41  * memory slice ID and the high-order bits are the SSM nodeid.
42  */
43 
44 #ifndef	MAX_MEM_NODES
45 #define	MAX_MEM_NODES	(8)
46 #endif	/* MAX_MEM_NODES */
47 
48 #define	PFN_2_MEM_NODE(pfn)			\
49 	((max_mem_nodes > 1) ? plat_pfn_to_mem_node(pfn) : 0)
50 
51 #define	MEM_NODE_2_LGRPHAND(mnode)		\
52 	((max_mem_nodes > 1) ? plat_mem_node_to_lgrphand(mnode) : \
53 	    LGRP_DEFAULT_HANDLE)
54 
55 /*
56  * Platmod hooks
57  */
58 
59 extern int plat_pfn_to_mem_node(pfn_t);
60 extern int plat_lgrphand_to_mem_node(lgrp_handle_t);
61 extern void plat_assign_lgrphand_to_mem_node(lgrp_handle_t, int);
62 extern lgrp_handle_t plat_mem_node_to_lgrphand(int);
63 extern void plat_slice_add(pfn_t, pfn_t);
64 extern void plat_slice_del(pfn_t, pfn_t);
65 
66 #pragma	weak plat_pfn_to_mem_node
67 #pragma	weak plat_lgrphand_to_mem_node
68 #pragma	weak plat_mem_node_to_lgrphand
69 #pragma	weak plat_slice_add
70 #pragma	weak plat_slice_del
71 
72 struct	mem_node_conf {
73 	int	exists;		/* only try if set, list may still be empty */
74 	pfn_t	physbase;	/* lowest PFN in this memnode */
75 	pfn_t	physmax;	/* highest PFN in this memnode */
76 };
77 
78 struct memlist;
79 
80 extern void startup_build_mem_nodes(struct memlist *);
81 extern void mem_node_add_slice(pfn_t, pfn_t);
82 extern void mem_node_del_slice(pfn_t, pfn_t);
83 extern int mem_node_alloc(void);
84 extern pgcnt_t mem_node_memlist_pages(int, struct memlist *);
85 extern void mem_node_add_range(pfn_t, pfn_t);
86 extern void mem_node_del_range(pfn_t, pfn_t);
87 
88 extern int plat_mnode_xcheck(pfn_t);
89 
90 extern struct mem_node_conf	mem_node_config[];
91 extern uint64_t			mem_node_physalign;
92 extern int			mem_node_pfn_shift;
93 extern int			max_mem_nodes;
94 
95 extern uint_t			lgrp_plat_node_cnt;
96 
97 #endif	/* _KERNEL */
98 
99 #ifdef	__cplusplus
100 }
101 #endif
102 
103 #endif	/* _SYS_MEMNODE_H */
104