17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*ce8eb11aSdp78419 * Common Development and Distribution License (the "License"). 6*ce8eb11aSdp78419 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*ce8eb11aSdp78419 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_MEMNODE_H 277c478bd9Sstevel@tonic-gate #define _SYS_MEMNODE_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef _KERNEL 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <sys/lgrp.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* 407c478bd9Sstevel@tonic-gate * This file defines the mappings between physical addresses and memory 417c478bd9Sstevel@tonic-gate * nodes. Memory nodes are defined so that the low-order bits are the 427c478bd9Sstevel@tonic-gate * memory slice ID and the high-order bits are the SSM nodeid. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * The MAX_MEM_NODES constant is the maximum number of memory nodes for the 477c478bd9Sstevel@tonic-gate * unix binary and is used to help size static data structures. The 487c478bd9Sstevel@tonic-gate * max_mem_nodes variable is the maximum number of memory nodes for the 497c478bd9Sstevel@tonic-gate * running platform and may be smaller than MAX_MEM_NODES since the platform 507c478bd9Sstevel@tonic-gate * may not need to use all of them. 517c478bd9Sstevel@tonic-gate * 527c478bd9Sstevel@tonic-gate * The default value of MAX_MEM_NODES is 4 to create enough memory nodes for 537c478bd9Sstevel@tonic-gate * Chalupa and max_mem_nodes is set to 1 by default since the generic sun4u 547c478bd9Sstevel@tonic-gate * unix binary mostly includes platforms only needing one memory node. 557c478bd9Sstevel@tonic-gate * For platforms requiring more than one memory node, max_mem_nodes is set to 567c478bd9Sstevel@tonic-gate * a bigger value in the lgroup platform initialization routines which are 577c478bd9Sstevel@tonic-gate * called before the memory nodes are initialized. Some platforms like 587c478bd9Sstevel@tonic-gate * Serengeti and Starcat simply define MAX_MEM_NODES to be their respective 597c478bd9Sstevel@tonic-gate * maximum memory nodes at compile time, since they have their own unix binary 607c478bd9Sstevel@tonic-gate * and don't share one with any other platform like Enchilada and Chalupa do. 617c478bd9Sstevel@tonic-gate * 627c478bd9Sstevel@tonic-gate * For machines that don't support DR, they can set max_mem_nodes to the actual 637c478bd9Sstevel@tonic-gate * number of memory nodes in the running system instead of the maximum. The 647c478bd9Sstevel@tonic-gate * platform controls the mapping of lgroup platform handles and PFNs to memory 657c478bd9Sstevel@tonic-gate * nodes, so the platform can always make everything work. 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate #ifndef MAX_MEM_NODES 697c478bd9Sstevel@tonic-gate #define MAX_MEM_NODES (4) 707c478bd9Sstevel@tonic-gate #endif /* MAX_MEM_NODES */ 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate #define PFN_2_MEM_NODE(pfn) \ 737c478bd9Sstevel@tonic-gate ((max_mem_nodes > 1) ? plat_pfn_to_mem_node(pfn) : 0) 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate #define MEM_NODE_2_LGRPHAND(mnode) \ 767c478bd9Sstevel@tonic-gate ((max_mem_nodes > 1) ? plat_mem_node_to_lgrphand(mnode) : \ 777c478bd9Sstevel@tonic-gate LGRP_DEFAULT_HANDLE) 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* 807c478bd9Sstevel@tonic-gate * Platmod hooks 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate extern int plat_pfn_to_mem_node(pfn_t); 847c478bd9Sstevel@tonic-gate extern int plat_lgrphand_to_mem_node(lgrp_handle_t); 857c478bd9Sstevel@tonic-gate extern void plat_assign_lgrphand_to_mem_node(lgrp_handle_t, int); 867c478bd9Sstevel@tonic-gate extern lgrp_handle_t plat_mem_node_to_lgrphand(int); 877c478bd9Sstevel@tonic-gate extern void plat_slice_add(pfn_t, pfn_t); 887c478bd9Sstevel@tonic-gate extern void plat_slice_del(pfn_t, pfn_t); 89*ce8eb11aSdp78419 extern void plat_mem_node_intersect_range(pfn_t, pgcnt_t, int, pgcnt_t *); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #pragma weak plat_pfn_to_mem_node 927c478bd9Sstevel@tonic-gate #pragma weak plat_lgrphand_to_mem_node 937c478bd9Sstevel@tonic-gate #pragma weak plat_mem_node_to_lgrphand 947c478bd9Sstevel@tonic-gate #pragma weak plat_slice_add 957c478bd9Sstevel@tonic-gate #pragma weak plat_slice_del 96*ce8eb11aSdp78419 #pragma weak plat_mem_node_intersect_range 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate struct mem_node_conf { 997c478bd9Sstevel@tonic-gate int exists; /* only try if set, list may still be empty */ 1007c478bd9Sstevel@tonic-gate pfn_t physbase; /* lowest PFN in this memnode */ 1017c478bd9Sstevel@tonic-gate pfn_t physmax; /* highest PFN in this memnode */ 1027c478bd9Sstevel@tonic-gate }; 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate struct memlist; 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate extern void startup_build_mem_nodes(u_longlong_t *, size_t); 1077c478bd9Sstevel@tonic-gate extern void mem_node_add_slice(pfn_t, pfn_t); 1087c478bd9Sstevel@tonic-gate extern void mem_node_pre_del_slice(pfn_t, pfn_t); 1097c478bd9Sstevel@tonic-gate extern void mem_node_post_del_slice(pfn_t, pfn_t, int); 1107c478bd9Sstevel@tonic-gate extern int mem_node_alloc(void); 1117c478bd9Sstevel@tonic-gate extern pgcnt_t mem_node_memlist_pages(int, struct memlist *); 112*ce8eb11aSdp78419 extern void mem_node_add_slice(pfn_t start, pfn_t end); 113*ce8eb11aSdp78419 extern void mem_node_max_range(pfn_t *, pfn_t *); 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate extern struct mem_node_conf mem_node_config[]; 1167c478bd9Sstevel@tonic-gate extern uint64_t mem_node_physalign; 1177c478bd9Sstevel@tonic-gate extern int mem_node_pfn_shift; 1187c478bd9Sstevel@tonic-gate extern int max_mem_nodes; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1237c478bd9Sstevel@tonic-gate } 1247c478bd9Sstevel@tonic-gate #endif 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate #endif /* _SYS_MEMNODE_H */ 127