xref: /titanic_50/usr/src/uts/i86pc/sys/memnode.h (revision 686928d476b99b8b21fe0d4ae0ddcc1936cd0bd6)
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 #define	MAX_MEM_NODES_PER_LGROUP	3
45 #ifndef	MAX_MEM_NODES
46 #define	MAX_MEM_NODES			(8 * MAX_MEM_NODES_PER_LGROUP)
47 #endif	/* MAX_MEM_NODES */
48 
49 #define	PFN_2_MEM_NODE(pfn)			\
50 	((max_mem_nodes > 1) ? plat_pfn_to_mem_node(pfn) : 0)
51 
52 #define	MEM_NODE_2_LGRPHAND(mnode)		\
53 	((max_mem_nodes > 1) ? plat_mem_node_to_lgrphand(mnode) : \
54 	    LGRP_DEFAULT_HANDLE)
55 
56 /*
57  * Platmod hooks
58  */
59 
60 extern int plat_pfn_to_mem_node(pfn_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_mem_node_to_lgrphand
68 #pragma	weak plat_slice_add
69 #pragma	weak plat_slice_del
70 
71 struct	mem_node_conf {
72 	int	exists;		/* only try if set, list may still be empty */
73 	pfn_t	physbase;	/* lowest PFN in this memnode */
74 	pfn_t	physmax;	/* highest PFN in this memnode */
75 };
76 
77 struct memlist;
78 
79 extern void startup_build_mem_nodes(struct memlist *);
80 extern void mem_node_add_slice(pfn_t, pfn_t);
81 extern void mem_node_del_slice(pfn_t, pfn_t);
82 extern int mem_node_alloc(void);
83 extern pgcnt_t mem_node_memlist_pages(int, struct memlist *);
84 extern void mem_node_add_range(pfn_t, pfn_t);
85 extern void mem_node_del_range(pfn_t, pfn_t);
86 
87 extern int plat_mnode_xcheck(pfn_t);
88 
89 extern struct mem_node_conf	mem_node_config[];
90 extern uint64_t			mem_node_physalign;
91 extern int			mem_node_pfn_shift;
92 extern int			max_mem_nodes;
93 
94 extern uint_t			lgrp_plat_node_cnt;
95 
96 #endif	/* _KERNEL */
97 
98 #ifdef	__cplusplus
99 }
100 #endif
101 
102 #endif	/* _SYS_MEMNODE_H */
103