1 /* $NetBSD: pmap.h,v 1.7 2008/04/28 20:24:14 martin Exp $ */
4 * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * only pull in the headers once. if we attempt to pull them in
34 * again, we get namespace collisions on some structures, and we don't
35 * want to redefine some of them since it will affect the layout of
45 #include <sys/types.h>
46 #include <sys/param.h>
48 #include <sys/vnode.h>
49 #include <sys/mount.h>
51 #include <sys/namei.h>
52 #include <sys/sysctl.h>
55 #include <uvm/uvm_device.h>
57 #include <ufs/ufs/inode.h>
60 #include <isofs/cd9660/iso.h>
61 #include <isofs/cd9660/cd9660_node.h>
64 #endif /* PMAP_HEADERS */
67 * if the definition of the kbit structure (and the accessor macros)
68 * is already established, don't redefine it.
73 * stolen (and munged) from #include <uvm/uvm_object.h>
75 #define UVM_OBJ_IS_VNODE(uobj) ((uobj)->pgops == uvm_vnodeops)
76 #define UVM_OBJ_IS_AOBJ(uobj) ((uobj)->pgops == aobj_pager)
77 #define UVM_OBJ_IS_DEVICE(uobj) ((uobj)->pgops == uvm_deviceops)
78 #define UVM_OBJ_IS_UBCPAGER(uobj) ((uobj)->pgops == ubc_pager)
81 * stolen from #include <uvm/uvm_amap.h>
83 #define PPREF_NONE ((int *) -1)
85 /* the size of the object in the kernel */
86 #define S(x) ((x)->k_size)
87 /* the address of the object in kernel, two forms */
88 #define A(x) ((x)->k_addr.k_addr_ul)
89 #define P(x) ((x)->k_addr.k_addr_p)
90 /* the data from the kernel */
91 #define D(x,d) (&((x)->k_data.d))
93 /* suck the data from the kernel */
94 #define _KDEREFOK(kd, addr, dst, sz) \
95 ((size_t)kvm_read((kd), (addr), (dst), (sz)) == (size_t)(sz))
96 #define _KDEREF(kd, addr, dst, sz) do { \
97 if (!_KDEREFOK((kd), (addr), (dst), (sz))) \
98 errx(1, "trying to read %lu bytes from %lx: %s", \
99 (unsigned long)(sz), (addr), kvm_geterr(kd)); \
100 } while (0/*CONSTCOND*/)
102 /* suck the data using the structure */
103 #define KDEREFOK(kd, item) _KDEREFOK((kd), A(item), D(item, data), S(item))
104 #define KDEREF(kd, item) _KDEREF((kd), A(item), D(item, data), S(item))
113 * something for printf() and something for kvm_read()
121 * where we actually put the "stuff"
125 struct vmspace vmspace
;
126 struct vm_map vm_map
;
127 struct vm_map_entry vm_map_entry
;
129 struct uvm_object uvm_object
;
131 struct namecache namecache
;
133 struct iso_node iso_node
;
134 struct uvm_device uvm_device
;
140 #endif /* struct_kbit */
143 * this is the *actual* module interface
146 void process_map(kvm_t
*, struct kinfo_proc2
*,
147 struct kbit
*, const char *);
148 void dump_vm_map(kvm_t
*, struct kinfo_proc2
*,
149 struct kbit
*, struct kbit
*, const char *);
150 size_t dump_vm_map_entry(kvm_t
*, struct kinfo_proc2
*,
151 struct kbit
*, struct kbit
*, int);
152 void dump_amap(kvm_t
*, struct kbit
*);