1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1997-2001 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_MEM_CONFIG_H 28*0Sstevel@tonic-gate #define _SYS_MEM_CONFIG_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate * Memory add/delete interfaces. 34*0Sstevel@tonic-gate */ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #ifdef __cplusplus 37*0Sstevel@tonic-gate extern "C" { 38*0Sstevel@tonic-gate #endif 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #ifdef _KERNEL 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate /* 43*0Sstevel@tonic-gate * Memory add/delete client interface. 44*0Sstevel@tonic-gate */ 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate extern int kphysm_add_memory_dynamic(pfn_t base, pgcnt_t npgs); 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate typedef void *memhandle_t; 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate /* 51*0Sstevel@tonic-gate * Managed pages have associated page structures ('page_t's). 52*0Sstevel@tonic-gate * The difference between phys_pages and managed is accounted for by 53*0Sstevel@tonic-gate * boot time memory allocation for the kernel text and data, and also 54*0Sstevel@tonic-gate * for page structures. 55*0Sstevel@tonic-gate */ 56*0Sstevel@tonic-gate typedef struct { 57*0Sstevel@tonic-gate pgcnt_t phys_pages; /* total physical pages */ 58*0Sstevel@tonic-gate pgcnt_t managed; /* providing this many managed pages */ 59*0Sstevel@tonic-gate pgcnt_t nonrelocatable; /* of which this many non-relocatable */ 60*0Sstevel@tonic-gate pfn_t first_nonrelocatable; 61*0Sstevel@tonic-gate pfn_t last_nonrelocatable; 62*0Sstevel@tonic-gate } memquery_t; 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate typedef struct { 65*0Sstevel@tonic-gate pgcnt_t phys_pages; /* total physical pages */ 66*0Sstevel@tonic-gate pgcnt_t managed; /* providing this many managed pages */ 67*0Sstevel@tonic-gate pgcnt_t collected; /* done when == managed */ 68*0Sstevel@tonic-gate } memdelstat_t; 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate extern int kphysm_del_gethandle(memhandle_t *); 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate extern int kphysm_del_span(memhandle_t, pfn_t base, pgcnt_t npgs); 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate extern int kphysm_del_span_query(pfn_t base, pgcnt_t npgs, memquery_t *); 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate extern int kphysm_del_start(memhandle_t, 77*0Sstevel@tonic-gate void (*complete)(void *, int error), void *arg); 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate extern int kphysm_del_release(memhandle_t); 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate extern int kphysm_del_cancel(memhandle_t); 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate extern int kphysm_del_status(memhandle_t, memdelstat_t *); 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate /* 86*0Sstevel@tonic-gate * Error returns. 87*0Sstevel@tonic-gate */ 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate #define KPHYSM_OK 0 /* Success */ 90*0Sstevel@tonic-gate #define KPHYSM_ESPAN 1 /* Memory already in use (add) */ 91*0Sstevel@tonic-gate #define KPHYSM_EFAULT 2 /* Memory access test failed (add) */ 92*0Sstevel@tonic-gate #define KPHYSM_ERESOURCE 3 /* Some resource was not available */ 93*0Sstevel@tonic-gate #define KPHYSM_ENOTSUP 4 /* Operation not supported */ 94*0Sstevel@tonic-gate #define KPHYSM_ENOHANDLES 5 /* Cannot allocate any more handles */ 95*0Sstevel@tonic-gate #define KPHYSM_ENONRELOC 6 /* Non-relocatable pages in span */ 96*0Sstevel@tonic-gate #define KPHYSM_EHANDLE 7 /* Bad handle supplied */ 97*0Sstevel@tonic-gate #define KPHYSM_EBUSY 8 /* Memory in span is being deleted */ 98*0Sstevel@tonic-gate #define KPHYSM_ENOTVIABLE 9 /* VM viability test failed */ 99*0Sstevel@tonic-gate #define KPHYSM_ESEQUENCE 10 /* Function called out of sequence */ 100*0Sstevel@tonic-gate #define KPHYSM_ENOWORK 11 /* No pages to delete */ 101*0Sstevel@tonic-gate #define KPHYSM_ECANCELLED 12 /* kphysm_del_cancel (for complete) */ 102*0Sstevel@tonic-gate #define KPHYSM_EREFUSED 13 /* kphysm_pre_del fail (for complete) */ 103*0Sstevel@tonic-gate #define KPHYSM_ENOTFINISHED 14 /* Thread not finished */ 104*0Sstevel@tonic-gate #define KPHYSM_ENOTRUNNING 15 /* Thread not running */ 105*0Sstevel@tonic-gate #define KPHYSM_EDUP 16 /* Memory span duplicate (delete) */ 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate /* 108*0Sstevel@tonic-gate * Memory system change call-back interface. 109*0Sstevel@tonic-gate */ 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate #define KPHYSM_SETUP_VECTOR_VERSION 1 112*0Sstevel@tonic-gate typedef struct { 113*0Sstevel@tonic-gate uint_t version; 114*0Sstevel@tonic-gate void (*post_add)(void *arg, pgcnt_t delta_pages); 115*0Sstevel@tonic-gate int (*pre_del)(void *arg, pgcnt_t delta_pages); 116*0Sstevel@tonic-gate void (*post_del)(void *arg, pgcnt_t delta_pages, 117*0Sstevel@tonic-gate int cancelled); 118*0Sstevel@tonic-gate } kphysm_setup_vector_t; 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate /* 121*0Sstevel@tonic-gate * The register function returns 0 if the vector/arg pair is recorded 122*0Sstevel@tonic-gate * successfully. 123*0Sstevel@tonic-gate * The error returns are: 124*0Sstevel@tonic-gate * EEXIST if the vector/arg pair is already registered. 125*0Sstevel@tonic-gate * EINVAL if the vector version is not supported. 126*0Sstevel@tonic-gate * ENOMEM if the registration could not be stored. 127*0Sstevel@tonic-gate * 128*0Sstevel@tonic-gate * A return of EEXIST should be considered a program logic error by 129*0Sstevel@tonic-gate * the caller. 130*0Sstevel@tonic-gate */ 131*0Sstevel@tonic-gate extern int kphysm_setup_func_register(kphysm_setup_vector_t *, void *arg); 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate extern void kphysm_setup_func_unregister(kphysm_setup_vector_t *, void *arg); 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate /* 137*0Sstevel@tonic-gate * Memory add/delete architecture (lower) interfaces. 138*0Sstevel@tonic-gate * These interfaces should not be used by drivers. 139*0Sstevel@tonic-gate */ 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate extern int arch_kphysm_del_span_ok(pfn_t, pgcnt_t); 142*0Sstevel@tonic-gate extern int arch_kphysm_relocate(pfn_t, pgcnt_t); 143*0Sstevel@tonic-gate extern int arch_kphysm_del_supported(void); 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate extern int pfn_is_being_deleted(pfn_t); 146*0Sstevel@tonic-gate 147*0Sstevel@tonic-gate extern void memsegs_lock(int); 148*0Sstevel@tonic-gate extern void memsegs_unlock(int); 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate #endif /* _KERNEL */ 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate #ifdef __cplusplus 153*0Sstevel@tonic-gate } 154*0Sstevel@tonic-gate #endif 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate #endif /* _SYS_MEM_CONFIG_H */ 157