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*ae115bc7Smrj * Common Development and Distribution License (the "License"). 6*ae115bc7Smrj * 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*ae115bc7Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*ae115bc7Smrj * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_MEM_CONFIG_H 277c478bd9Sstevel@tonic-gate #define _SYS_MEM_CONFIG_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate /* 327c478bd9Sstevel@tonic-gate * Memory add/delete interfaces. 337c478bd9Sstevel@tonic-gate */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef _KERNEL 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * Memory add/delete client interface. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate extern int kphysm_add_memory_dynamic(pfn_t base, pgcnt_t npgs); 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate typedef void *memhandle_t; 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * Managed pages have associated page structures ('page_t's). 517c478bd9Sstevel@tonic-gate * The difference between phys_pages and managed is accounted for by 527c478bd9Sstevel@tonic-gate * boot time memory allocation for the kernel text and data, and also 537c478bd9Sstevel@tonic-gate * for page structures. 547c478bd9Sstevel@tonic-gate */ 557c478bd9Sstevel@tonic-gate typedef struct { 567c478bd9Sstevel@tonic-gate pgcnt_t phys_pages; /* total physical pages */ 577c478bd9Sstevel@tonic-gate pgcnt_t managed; /* providing this many managed pages */ 587c478bd9Sstevel@tonic-gate pgcnt_t nonrelocatable; /* of which this many non-relocatable */ 597c478bd9Sstevel@tonic-gate pfn_t first_nonrelocatable; 607c478bd9Sstevel@tonic-gate pfn_t last_nonrelocatable; 617c478bd9Sstevel@tonic-gate } memquery_t; 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate typedef struct { 647c478bd9Sstevel@tonic-gate pgcnt_t phys_pages; /* total physical pages */ 657c478bd9Sstevel@tonic-gate pgcnt_t managed; /* providing this many managed pages */ 667c478bd9Sstevel@tonic-gate pgcnt_t collected; /* done when == managed */ 677c478bd9Sstevel@tonic-gate } memdelstat_t; 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate extern int kphysm_del_gethandle(memhandle_t *); 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate extern int kphysm_del_span(memhandle_t, pfn_t base, pgcnt_t npgs); 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate extern int kphysm_del_span_query(pfn_t base, pgcnt_t npgs, memquery_t *); 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate extern int kphysm_del_start(memhandle_t, 767c478bd9Sstevel@tonic-gate void (*complete)(void *, int error), void *arg); 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate extern int kphysm_del_release(memhandle_t); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate extern int kphysm_del_cancel(memhandle_t); 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate extern int kphysm_del_status(memhandle_t, memdelstat_t *); 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * Error returns. 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate #define KPHYSM_OK 0 /* Success */ 897c478bd9Sstevel@tonic-gate #define KPHYSM_ESPAN 1 /* Memory already in use (add) */ 907c478bd9Sstevel@tonic-gate #define KPHYSM_EFAULT 2 /* Memory access test failed (add) */ 917c478bd9Sstevel@tonic-gate #define KPHYSM_ERESOURCE 3 /* Some resource was not available */ 927c478bd9Sstevel@tonic-gate #define KPHYSM_ENOTSUP 4 /* Operation not supported */ 937c478bd9Sstevel@tonic-gate #define KPHYSM_ENOHANDLES 5 /* Cannot allocate any more handles */ 947c478bd9Sstevel@tonic-gate #define KPHYSM_ENONRELOC 6 /* Non-relocatable pages in span */ 957c478bd9Sstevel@tonic-gate #define KPHYSM_EHANDLE 7 /* Bad handle supplied */ 967c478bd9Sstevel@tonic-gate #define KPHYSM_EBUSY 8 /* Memory in span is being deleted */ 977c478bd9Sstevel@tonic-gate #define KPHYSM_ENOTVIABLE 9 /* VM viability test failed */ 987c478bd9Sstevel@tonic-gate #define KPHYSM_ESEQUENCE 10 /* Function called out of sequence */ 997c478bd9Sstevel@tonic-gate #define KPHYSM_ENOWORK 11 /* No pages to delete */ 1007c478bd9Sstevel@tonic-gate #define KPHYSM_ECANCELLED 12 /* kphysm_del_cancel (for complete) */ 1017c478bd9Sstevel@tonic-gate #define KPHYSM_EREFUSED 13 /* kphysm_pre_del fail (for complete) */ 1027c478bd9Sstevel@tonic-gate #define KPHYSM_ENOTFINISHED 14 /* Thread not finished */ 1037c478bd9Sstevel@tonic-gate #define KPHYSM_ENOTRUNNING 15 /* Thread not running */ 1047c478bd9Sstevel@tonic-gate #define KPHYSM_EDUP 16 /* Memory span duplicate (delete) */ 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * Memory system change call-back interface. 1087c478bd9Sstevel@tonic-gate */ 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate #define KPHYSM_SETUP_VECTOR_VERSION 1 1117c478bd9Sstevel@tonic-gate typedef struct { 1127c478bd9Sstevel@tonic-gate uint_t version; 1137c478bd9Sstevel@tonic-gate void (*post_add)(void *arg, pgcnt_t delta_pages); 1147c478bd9Sstevel@tonic-gate int (*pre_del)(void *arg, pgcnt_t delta_pages); 1157c478bd9Sstevel@tonic-gate void (*post_del)(void *arg, pgcnt_t delta_pages, 1167c478bd9Sstevel@tonic-gate int cancelled); 1177c478bd9Sstevel@tonic-gate } kphysm_setup_vector_t; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate /* 1207c478bd9Sstevel@tonic-gate * The register function returns 0 if the vector/arg pair is recorded 1217c478bd9Sstevel@tonic-gate * successfully. 1227c478bd9Sstevel@tonic-gate * The error returns are: 1237c478bd9Sstevel@tonic-gate * EEXIST if the vector/arg pair is already registered. 1247c478bd9Sstevel@tonic-gate * EINVAL if the vector version is not supported. 1257c478bd9Sstevel@tonic-gate * ENOMEM if the registration could not be stored. 1267c478bd9Sstevel@tonic-gate * 1277c478bd9Sstevel@tonic-gate * A return of EEXIST should be considered a program logic error by 1287c478bd9Sstevel@tonic-gate * the caller. 1297c478bd9Sstevel@tonic-gate */ 1307c478bd9Sstevel@tonic-gate extern int kphysm_setup_func_register(kphysm_setup_vector_t *, void *arg); 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate extern void kphysm_setup_func_unregister(kphysm_setup_vector_t *, void *arg); 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate /* 1367c478bd9Sstevel@tonic-gate * Memory add/delete architecture (lower) interfaces. 1377c478bd9Sstevel@tonic-gate * These interfaces should not be used by drivers. 1387c478bd9Sstevel@tonic-gate */ 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate extern int arch_kphysm_del_span_ok(pfn_t, pgcnt_t); 1417c478bd9Sstevel@tonic-gate extern int arch_kphysm_relocate(pfn_t, pgcnt_t); 1427c478bd9Sstevel@tonic-gate extern int arch_kphysm_del_supported(void); 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate extern int pfn_is_being_deleted(pfn_t); 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate #endif 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #endif /* _SYS_MEM_CONFIG_H */ 153