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