as.h revision 406882169e00272f14067d948324d690893e6fe3
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#ifndef _VM_AS_H
#define _VM_AS_H
#include <sys/watchpoint.h>
#include <vm/faultcode.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* VM - Address spaces.
*/
/*
* Each address space consists of a sorted list of segments
* and machine dependent address translation information.
*
* All the hard work is in the segment drivers and the
* hardware address translation code.
*
* The segment list is represented as an AVL tree.
*
* The address space lock (a_lock) is a long term lock which serializes
* access to certain operations (as_map, as_unmap) and protects the
* underlying generic segment data (seg.h) along with some fields in the
* address space structure as shown below:
*
* address space structure segment structure
*
* a_segtree s_base
* a_size s_size
* a_lastgap s_link
* a_seglast s_ops
* s_as
* s_data
*
* The address space contents lock (a_contents) is a short term
* lock that protects most of the data in the address space structure.
* This lock is always acquired after the "a_lock" in all situations
* except while dealing with AS_CLAIMGAP to avoid deadlocks.
*
* The following fields are protected by this lock:
*
* a_flags (AS_PAGLCK, AS_CLAIMGAP, etc.)
* a_unmapwait
* a_seglast
*
* The address space lock (a_lock) is always held prior to any segment
* operation. Some segment drivers use the address space lock to protect
* some or all of their segment private data, provided the version of
* "a_lock" (read vs. write) is consistent with the use of the data.
*
* The following fields are protected by the hat layer lock:
*
* a_vbits
* a_hat
* a_hrm
*/
struct as {
/* AS_HI or AS_LO used in as_addseg() */
void *a_xhat; /* list of xhat providers */
};
#define AS_PAGLCK 0x80
#define AS_CLAIMGAP 0x40
#define AS_UNMAPWAIT 0x20
#define AS_NOUNMAPWAIT 0x02
#define AS_TYPE_64BIT(as) \
/*
* Flags for as_map/as_map_ansegs
*/
/*
* The as_callback is the basic structure which supports the ability to
* inform clients of specific events pertaining to address space management.
* A user calls as_add_callback to register an address space callback
* for a range of pages, specifying the events that need to occur.
* When as_do_callbacks is called and finds a 'matching' entry, the
* callback is called once, and the callback function MUST call
* as_delete_callback when all callback activities are complete.
* The thread calling as_do_callbacks blocks until the as_delete_callback
* is called. This allows for asynchorous events to subside before the
* as_do_callbacks thread continues.
*
* An example of the need for this is a driver which has done long-term
* locking of memory. Address space management operations (events) such
* as as_free, as_umap, and as_setprot will block indefinitely until the
* pertinent memory is unlocked. The callback mechanism provides the
* way to inform the driver of the event so that the driver may do the
* necessary unlocking.
*
* The contents of this structure is protected by a_contents lock
*/
struct as_callback {
void *ascb_arg; /* callback argument */
};
/*
* Callback events
*/
#define AS_FREE_EVENT 0x1
#define AS_SETPROT_EVENT 0x2
#define AS_UNMAP_EVENT 0x4
#define AS_UNMAPWAIT_EVENT \
#define AS_ALL_EVENT \
/* Return code values for as_callback_delete */
enum as_cbdelete_rc {
};
#ifdef _KERNEL
/*
* Flags for as_gap.
*/
/*
* Macros for address space locking.
*/
/*
* Macros to test lock states.
*/
/*
* macros to walk thru segment lists
*/
void as_init(void);
void as_avlinit(struct as *);
void *argsp);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _VM_AS_H */