1998-10-19 03:49:59 +04:00
|
|
|
/* $NetBSD: uvm_amap.h,v 1.8 1998/10/18 23:49:59 chs Exp $ */
|
1998-02-05 09:25:08 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXXCDC: "ROUGH DRAFT" QUALITY UVM PRE-RELEASE FILE!
|
|
|
|
* >>>USE AT YOUR OWN RISK, WORK IS NOT FINISHED<<<
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997 Charles D. Cranor and Washington University.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Charles D. Cranor and
|
|
|
|
* Washington University.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1998-02-07 14:07:38 +03:00
|
|
|
*
|
|
|
|
* from: Id: uvm_amap.h,v 1.1.2.7 1998/01/05 18:12:56 chuck Exp
|
1998-02-05 09:25:08 +03:00
|
|
|
*/
|
|
|
|
|
1998-02-10 05:34:17 +03:00
|
|
|
#ifndef _UVM_UVM_AMAP_H_
|
|
|
|
#define _UVM_UVM_AMAP_H_
|
|
|
|
|
1998-02-05 09:25:08 +03:00
|
|
|
/*
|
|
|
|
* uvm_amap.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* defines for handling of large sparce amaps.
|
|
|
|
*
|
|
|
|
* currently the kernel likes to allocate large chunks of VM to reserve
|
|
|
|
* them for possible use. for example, it allocates (reserves) a large
|
|
|
|
* chunk of user VM for possible stack growth. most of the time only
|
|
|
|
* a page or two of this VM is actually used. since the stack is anonymous
|
|
|
|
* memory it makes sense for it to live in an amap, but if we allocated
|
|
|
|
* an amap for the entire stack range we could end up wasting a large
|
|
|
|
* amount of malloc'd KVM.
|
|
|
|
*
|
|
|
|
* for example, on the i386 at boot time we allocate two amaps for the stack
|
|
|
|
* of /sbin/init:
|
|
|
|
* 1. a 7680 slot amap at protection 0 (reserve space for stack)
|
|
|
|
* 2. a 512 slot amap at protection 7 (top of stack)
|
|
|
|
*
|
|
|
|
* most of that VM is never mapped or used.
|
|
|
|
*
|
|
|
|
* to avoid allocating amap resources for the whole range we have the
|
|
|
|
* VM system look for maps that are larger than UVM_AMAP_LARGE slots
|
|
|
|
* (note that 1 slot = 1 vm_page). for maps that are large, we attempt
|
|
|
|
* to break them up into UVM_AMAP_CHUNK slot sized amaps.
|
|
|
|
*
|
|
|
|
* so, in the i386 example, the 7680 slot area is never referenced so
|
|
|
|
* nothing gets allocated. the 512 slot area is referenced, and it
|
|
|
|
* gets divided into 16 slot chunks (hopefully with one 16 slot chunk
|
|
|
|
* being enough to handle the whole stack...).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define UVM_AMAP_LARGE 256 /* # of slots in "large" amap */
|
|
|
|
#define UVM_AMAP_CHUNK 16 /* # of slots to chunk large amaps in */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
#define AMAP_B2SLOT(S,B) { \
|
1998-10-19 03:49:59 +04:00
|
|
|
if ((B) & (PAGE_SIZE - 1)) \
|
1998-02-05 09:25:08 +03:00
|
|
|
panic("AMAP_B2SLOT: invalid byte count"); \
|
1998-10-19 03:49:59 +04:00
|
|
|
(S) = (B) >> PAGE_SHIFT; \
|
1998-02-05 09:25:08 +03:00
|
|
|
}
|
|
|
|
#else
|
1998-10-19 03:49:59 +04:00
|
|
|
#define AMAP_B2SLOT(S,B) (S) = (B) >> PAGE_SHIFT
|
1998-02-05 09:25:08 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VM_AMAP_PPREF
|
|
|
|
#define PPREF_NONE ((int *) -1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* handle inline options
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef UVM_AMAP_INLINE
|
|
|
|
#define AMAP_INLINE static __inline
|
|
|
|
#else
|
|
|
|
#define AMAP_INLINE /* nothing */
|
|
|
|
#endif /* UVM_AMAP_INLINE */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes: the following prototypes define the interface to amaps
|
|
|
|
*/
|
|
|
|
|
1998-08-13 06:10:37 +04:00
|
|
|
AMAP_INLINE vaddr_t amap_add __P((struct vm_aref *, vaddr_t,
|
1998-03-09 03:58:55 +03:00
|
|
|
struct vm_anon *, int));
|
1998-08-13 06:10:37 +04:00
|
|
|
struct vm_amap *amap_alloc __P((vaddr_t, vaddr_t, int));
|
1998-02-05 09:25:08 +03:00
|
|
|
void amap_copy __P((vm_map_t, vm_map_entry_t, int, boolean_t,
|
1998-08-13 06:10:37 +04:00
|
|
|
vaddr_t, vaddr_t));
|
1998-02-05 09:25:08 +03:00
|
|
|
void amap_cow_now __P((vm_map_t, vm_map_entry_t));
|
1998-08-13 06:10:37 +04:00
|
|
|
void amap_extend __P((vm_map_entry_t, vsize_t));
|
1998-02-05 09:25:08 +03:00
|
|
|
void amap_free __P((struct vm_amap *));
|
1998-08-13 06:10:37 +04:00
|
|
|
AMAP_INLINE struct vm_anon *amap_lookup __P((struct vm_aref *, vaddr_t));
|
|
|
|
AMAP_INLINE void amap_lookups __P((struct vm_aref *, vaddr_t,
|
1998-02-05 09:25:08 +03:00
|
|
|
struct vm_anon **, int));
|
|
|
|
#ifdef VM_AMAP_PPREF
|
1998-08-13 06:10:37 +04:00
|
|
|
void amap_pp_adjref __P((struct vm_amap *, int, vsize_t, int));
|
1998-02-05 09:25:08 +03:00
|
|
|
void amap_pp_establish __P((struct vm_amap *));
|
|
|
|
#endif
|
|
|
|
AMAP_INLINE void amap_ref __P((vm_map_entry_t, int));
|
|
|
|
void amap_share_protect __P((vm_map_entry_t, vm_prot_t));
|
1998-08-13 06:10:37 +04:00
|
|
|
void amap_splitref __P((struct vm_aref *, struct vm_aref *, vaddr_t));
|
|
|
|
AMAP_INLINE void amap_unadd __P((struct vm_amap *, vaddr_t));
|
1998-02-05 09:25:08 +03:00
|
|
|
AMAP_INLINE void amap_unref __P((vm_map_entry_t, int));
|
|
|
|
void amap_wipeout __P((struct vm_amap *));
|
|
|
|
#ifdef VM_AMAP_PPREF
|
|
|
|
void amap_wiperange __P((struct vm_amap *, int, int));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct vm_anon *uvm_analloc __P((void));
|
|
|
|
void uvm_anfree __P((struct vm_anon *));
|
|
|
|
void uvm_anon_init __P((void));
|
|
|
|
void uvm_anon_add __P((int));
|
|
|
|
struct vm_page *uvm_anon_lockloanpg __P((struct vm_anon *));
|
1998-02-10 05:34:17 +03:00
|
|
|
|
|
|
|
#endif /* _UVM_UVM_AMAP_H_ */
|