seg_kp.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _VM_SEG_KP_H
#define _VM_SEG_KP_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* segkp (as in kernel pageable) is a segment driver that supports allocation
* of page-aligned variable size of vm resources.
*
* Each vm resource represents a page-aligned range of virtual addresses.
* The caller may specify whether the resource should include a redzone,
* be locked down, or be zero initialized.
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* Private information per overall segkp segment (as opposed
* to per resource within segment). There are as many anon slots
* allocated as there there are pages in the segment.
*/
struct segkp_segdata {
};
/*
* A hash table is used to aid in the lookup of a kpd's based on vaddr.
* Since the heaviest use of segkp occurs from segkp_*get and segkp_*release,
* the hashing is based on the vaddr used by these routines.
*/
#define SEGKP_HASH(vaddr) \
struct segkp_data {
int kp_cookie; /* index into cache array */
/* in segkp_segdata */
};
/*
* Flag bits
*
*/
/*
* A cache of segkp elements may be created via segkp_cache_init().
* The elements on the freelist all have the same len and flags value.
* The cookie passed to the client is an index into the freelist array.
*/
struct segkp_cache {
int kpf_max; /* max # of elements allowed */
int kpf_count; /* current no. of elments */
int kpf_inuse; /* list inuse */
};
/*
* Define redzone, and stack_to_memory macros.
* The redzone is PAGESIZE bytes.
*/
#ifdef STACK_GROWTH_DOWN
#define KPD_REDZONE(kpd) (0)
#else /* STACK_GROWTH_DOWN */
#define stom(v) (v)
#endif /* STACK_GROWTH_DOWN */
/* If segkp becomes more than one seg this test will need changing. */
/*
* Public routine declarations not part of the segment ops vector go here.
*/
void segkp_cache_free();
int segkp_map_red(void);
void segkp_unmap_red(void);
/* Special currently only used by schedctl. */
struct anon_map; /* Make the compiler happy about the next line. */
/*
* We allow explicit calls to segkp_fault, even though it's part
* of the segkp ops vector.
*/
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _VM_SEG_KP_H */