root / lab4 / .minix-src / include / uvm / uvm_object.h @ 13
History | View | Annotate | Download (4.47 KB)
1 |
/* $NetBSD: uvm_object.h,v 1.33 2012/09/14 22:20:50 rmind Exp $ */
|
---|---|
2 |
|
3 |
/*
|
4 |
* Copyright (c) 1997 Charles D. Cranor and Washington University.
|
5 |
* All rights reserved.
|
6 |
*
|
7 |
* Redistribution and use in source and binary forms, with or without
|
8 |
* modification, are permitted provided that the following conditions
|
9 |
* are met:
|
10 |
* 1. Redistributions of source code must retain the above copyright
|
11 |
* notice, this list of conditions and the following disclaimer.
|
12 |
* 2. Redistributions in binary form must reproduce the above copyright
|
13 |
* notice, this list of conditions and the following disclaimer in the
|
14 |
* documentation and/or other materials provided with the distribution.
|
15 |
*
|
16 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
17 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
19 |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20 |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
21 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
22 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
23 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
25 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26 |
*
|
27 |
* from: Id: uvm_object.h,v 1.1.2.2 1998/01/04 22:44:51 chuck Exp
|
28 |
*/
|
29 |
|
30 |
#ifndef _UVM_UVM_OBJECT_H_
|
31 |
#define _UVM_UVM_OBJECT_H_
|
32 |
|
33 |
#include <sys/queue.h> |
34 |
#include <sys/rbtree.h> |
35 |
#include <uvm/uvm_pglist.h> |
36 |
|
37 |
/*
|
38 |
* The UVM memory object interface. Notes:
|
39 |
*
|
40 |
* A UVM memory object represents a list of pages, which are managed by
|
41 |
* the object's pager operations (uvm_object::pgops). All pages belonging
|
42 |
* to an object are owned by it and thus protected by the object lock.
|
43 |
*
|
44 |
* The lock (uvm_object::vmobjlock) may be shared amongst the UVM objects.
|
45 |
* By default, the lock is allocated dynamically using mutex_obj(9) cache.
|
46 |
* Lock sharing is normally used when there is an underlying object. For
|
47 |
* example, vnode representing a file may have an underlying node, which
|
48 |
* is the case for tmpfs and layered file systems. In such case, vnode's
|
49 |
* UVM object and the underlying UVM object shares the lock (note that the
|
50 |
* vnode_t::v_interlock points to uvm_object::vmobjlock).
|
51 |
*
|
52 |
* The reference count is managed atomically for the anonymous UVM objects.
|
53 |
* For other objects, it is arbitrary (may use the lock or atomics).
|
54 |
*/
|
55 |
|
56 |
struct uvm_object {
|
57 |
kmutex_t * vmobjlock; /* lock on memq */
|
58 |
const struct uvm_pagerops *pgops; /* pager ops */ |
59 |
struct pglist memq; /* pages in this object */ |
60 |
int uo_npages; /* # of pages in memq */ |
61 |
unsigned uo_refs; /* reference count */ |
62 |
struct rb_tree rb_tree; /* tree of pages */ |
63 |
LIST_HEAD(,ubc_map) uo_ubc; /* ubc mappings */
|
64 |
}; |
65 |
|
66 |
/*
|
67 |
* UVM_OBJ_KERN is a 'special' uo_refs value which indicates that the
|
68 |
* object is a kernel memory object rather than a normal one (kernel
|
69 |
* memory objects don't have reference counts -- they never die).
|
70 |
*
|
71 |
* this value is used to detected kernel object mappings at uvm_unmap()
|
72 |
* time. normally when an object is unmapped its pages eventaully become
|
73 |
* deactivated and then paged out and/or freed. this is not useful
|
74 |
* for kernel objects... when a kernel object is unmapped we always want
|
75 |
* to free the resources associated with the mapping. UVM_OBJ_KERN
|
76 |
* allows us to decide which type of unmapping we want to do.
|
77 |
*/
|
78 |
#define UVM_OBJ_KERN (-2) |
79 |
|
80 |
#define UVM_OBJ_IS_KERN_OBJECT(uobj) \
|
81 |
((uobj)->uo_refs == UVM_OBJ_KERN) |
82 |
|
83 |
#ifdef _KERNEL
|
84 |
|
85 |
extern const struct uvm_pagerops uvm_vnodeops; |
86 |
extern const struct uvm_pagerops uvm_deviceops; |
87 |
extern const struct uvm_pagerops ubc_pager; |
88 |
extern const struct uvm_pagerops aobj_pager; |
89 |
|
90 |
#define UVM_OBJ_IS_VNODE(uobj) \
|
91 |
((uobj)->pgops == &uvm_vnodeops) |
92 |
|
93 |
#define UVM_OBJ_IS_DEVICE(uobj) \
|
94 |
((uobj)->pgops == &uvm_deviceops) |
95 |
|
96 |
#define UVM_OBJ_IS_VTEXT(uobj) \
|
97 |
(UVM_OBJ_IS_VNODE(uobj) && uvn_text_p(uobj)) |
98 |
|
99 |
#define UVM_OBJ_IS_CLEAN(uobj) \
|
100 |
(UVM_OBJ_IS_VNODE(uobj) && uvn_clean_p(uobj)) |
101 |
|
102 |
/*
|
103 |
* UVM_OBJ_NEEDS_WRITEFAULT: true if the uobj needs to detect modification.
|
104 |
* (ie. wants to avoid writable user mappings.)
|
105 |
*
|
106 |
* XXX bad name
|
107 |
*/
|
108 |
|
109 |
#define UVM_OBJ_NEEDS_WRITEFAULT(uobj) \
|
110 |
(UVM_OBJ_IS_VNODE(uobj) && uvn_needs_writefault_p(uobj)) |
111 |
|
112 |
#define UVM_OBJ_IS_AOBJ(uobj) \
|
113 |
((uobj)->pgops == &aobj_pager) |
114 |
|
115 |
extern const rb_tree_ops_t uvm_page_tree_ops; |
116 |
|
117 |
#endif /* _KERNEL */ |
118 |
|
119 |
#endif /* _UVM_UVM_OBJECT_H_ */ |