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 2007 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 #include <sys/memlist_plat.h> 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 /* 47 * The MAX_MEM_NODES constant is the maximum number of memory nodes for the 48 * unix binary and is used to help size static data structures. The 49 * max_mem_nodes variable is the maximum number of memory nodes for the 50 * running platform and may be smaller than MAX_MEM_NODES since the platform 51 * may not need to use all of them. 52 * 53 * The default value of MAX_MEM_NODES is 4 to create enough memory nodes for 54 * Chalupa and max_mem_nodes is set to 1 by default since the generic sun4u 55 * unix binary mostly includes platforms only needing one memory node. 56 * For platforms requiring more than one memory node, max_mem_nodes is set to 57 * a bigger value in the lgroup platform initialization routines which are 58 * called before the memory nodes are initialized. Some platforms like 59 * Serengeti and Starcat simply define MAX_MEM_NODES to be their respective 60 * maximum memory nodes at compile time, since they have their own unix binary 61 * and don't share one with any other platform like Enchilada and Chalupa do. 62 * 63 * For machines that don't support DR, they can set max_mem_nodes to the actual 64 * number of memory nodes in the running system instead of the maximum. The 65 * platform controls the mapping of lgroup platform handles and PFNs to memory 66 * nodes, so the platform can always make everything work. 67 */ 68 69 #ifndef MAX_MEM_NODES 70 #define MAX_MEM_NODES (4) 71 #endif /* MAX_MEM_NODES */ 72 73 #define PFN_2_MEM_NODE(pfn) \ 74 ((max_mem_nodes > 1) ? plat_pfn_to_mem_node(pfn) : 0) 75 76 #define MEM_NODE_2_LGRPHAND(mnode) \ 77 ((max_mem_nodes > 1) ? plat_mem_node_to_lgrphand(mnode) : \ 78 LGRP_DEFAULT_HANDLE) 79 80 /* 81 * Platmod hooks 82 */ 83 84 extern int plat_pfn_to_mem_node(pfn_t); 85 extern int plat_lgrphand_to_mem_node(lgrp_handle_t); 86 extern void plat_assign_lgrphand_to_mem_node(lgrp_handle_t, int); 87 extern lgrp_handle_t plat_mem_node_to_lgrphand(int); 88 extern void plat_slice_add(pfn_t, pfn_t); 89 extern void plat_slice_del(pfn_t, pfn_t); 90 extern void plat_mem_node_intersect_range(pfn_t, pgcnt_t, int, pgcnt_t *); 91 92 #pragma weak plat_pfn_to_mem_node 93 #pragma weak plat_lgrphand_to_mem_node 94 #pragma weak plat_mem_node_to_lgrphand 95 #pragma weak plat_slice_add 96 #pragma weak plat_slice_del 97 #pragma weak plat_mem_node_intersect_range 98 99 struct mem_node_conf { 100 int exists; /* only try if set, list may still be empty */ 101 pfn_t physbase; /* lowest PFN in this memnode */ 102 pfn_t physmax; /* highest PFN in this memnode */ 103 }; 104 105 struct memlist; 106 107 extern void startup_build_mem_nodes(prom_memlist_t *, size_t); 108 extern void mem_node_add_slice(pfn_t, pfn_t); 109 extern void mem_node_pre_del_slice(pfn_t, pfn_t); 110 extern void mem_node_post_del_slice(pfn_t, pfn_t, int); 111 extern int mem_node_alloc(void); 112 extern pgcnt_t mem_node_memlist_pages(int, struct memlist *); 113 extern void mem_node_add_slice(pfn_t start, pfn_t end); 114 extern void mem_node_max_range(pfn_t *, pfn_t *); 115 116 extern struct mem_node_conf mem_node_config[]; 117 extern uint64_t mem_node_physalign; 118 extern int mem_node_pfn_shift; 119 extern int max_mem_nodes; 120 121 #endif /* _KERNEL */ 122 123 #ifdef __cplusplus 124 } 125 #endif 126 127 #endif /* _SYS_MEMNODE_H */ 128