seg.h revision 1bd5c35fd400f7f19eee9efd795c32cedb602b06
/*
* 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 2005 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_SEG_H
#define _VM_SEG_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <vm/seg_enum.h>
#include <vm/faultcode.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* VM - Segments.
*/
/*
* kstat statistics for segment advise
*/
typedef struct {
} segadvstat_t;
/*
* memory object ids
*/
/*
* An address space contains a set of segments, managed by drivers.
* Drivers support mapped devices, sharing, copy-on-write, etc.
*
* The seg structure contains a lock to prevent races, the base virtual
* address and size of the segment, a back pointer to the containing
* address space, pointers to maintain an AVL tree of segments in the
* same address space, and procedure and data hooks for the driver.
* The AVL tree of segments for the address space is sorted by
* ascending base addresses and overlapping segments are not allowed.
*
* After a segment is created, faults may occur on pages of the segment.
* When a fault occurs, the fault handling code must get the desired
* object and set up the hardware translation to the object. For some
* objects, the fault handling code also implements copy-on-write.
*
* When the hat wants to unload a translation, it can call the unload
* routine which is responsible for processing reference and modify bits.
*
* Each segment is protected by it's containing address space lock. To
* access any field in the segment structure, the "as" must be locked.
* If a segment field is to be modified, the address space lock must be
* write locked.
*/
struct seg {
void *s_data; /* private data for instance */
};
struct seg_ops {
enum fault_type, enum seg_rw);
size_t);
};
#ifdef _KERNEL
/*
* Generic segment operations
*/
extern void seg_init(void);
/*
* functions for pagelock cache support
*/
extern void seg_ppurge_seg(int (*callback)());
int (*callback)());
extern void seg_pasync_thread(void);
extern void seg_preap(void);
extern int seg_preapahead;
extern segadvstat_t segadvstat;
/*
* Flags for pagelock cache support
*/
/*
* Return values for seg_pinsert and seg_pinsert_check functions.
*/
#define SEGP_SUCCESS 0 /* seg_pinsert() succeeded */
/* Page status bits for segop_incore */
#define SEGOP_FAULT(h, s, a, l, t, rw) \
#define SEGOP_SYNC(s, a, l, atr, f) \
#define SEGOP_PAGELOCK(s, a, l, p, t, rw) \
#define SEGOP_SETPAGESIZE(s, a, l, szc) \
#define SEGP_PREDEL_DELAY_FACTOR 4
/*
* As a workaround to being unable to purge the pagelock
* cache during a DR delete memory operation, we use
* a stall threshold that is twice the maximum seen
* during testing. This workaround will be removed
* when a suitable fix is found.
*/
#define SEGP_STALL_SECONDS 25
#define SEGP_STALL_THRESHOLD \
#ifdef VMDEBUG
#endif /* VMDEBUG */
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _VM_SEG_H */