Home | History | Annotate | Line # | Download | only in pmap
pmap.h revision 1.5.18.1
      1  1.5.18.1    matt /*	$NetBSD: pmap.h,v 1.5.18.1 2008/01/09 02:00:52 matt Exp $ */
      2       1.1  atatat 
      3       1.1  atatat /*
      4       1.1  atatat  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
      5       1.1  atatat  * All rights reserved.
      6       1.1  atatat  *
      7       1.1  atatat  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1  atatat  * by Andrew Brown.
      9       1.1  atatat  *
     10       1.1  atatat  * Redistribution and use in source and binary forms, with or without
     11       1.1  atatat  * modification, are permitted provided that the following conditions
     12       1.1  atatat  * are met:
     13       1.1  atatat  * 1. Redistributions of source code must retain the above copyright
     14       1.1  atatat  *    notice, this list of conditions and the following disclaimer.
     15       1.1  atatat  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1  atatat  *    notice, this list of conditions and the following disclaimer in the
     17       1.1  atatat  *    documentation and/or other materials provided with the distribution.
     18       1.1  atatat  * 3. All advertising materials mentioning features or use of this software
     19       1.1  atatat  *    must display the following acknowledgement:
     20       1.1  atatat  *      This product includes software developed by the NetBSD
     21       1.1  atatat  *      Foundation, Inc. and its contributors.
     22       1.1  atatat  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23       1.1  atatat  *    contributors may be used to endorse or promote products derived
     24       1.1  atatat  *    from this software without specific prior written permission.
     25       1.1  atatat  *
     26       1.1  atatat  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27       1.1  atatat  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.1  atatat  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29       1.1  atatat  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30       1.1  atatat  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.1  atatat  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.1  atatat  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.1  atatat  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.1  atatat  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.1  atatat  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.1  atatat  * POSSIBILITY OF SUCH DAMAGE.
     37       1.1  atatat  */
     38       1.1  atatat 
     39       1.1  atatat /*
     40       1.1  atatat  * only pull in the headers once.  if we attempt to pull them in
     41       1.1  atatat  * again, we get namespace collisions on some structures, and we don't
     42       1.1  atatat  * want to redefine some of them since it will affect the layout of
     43       1.5  simonb  * the struct kbit.
     44       1.1  atatat  */
     45       1.1  atatat #ifndef PMAP_HEADERS
     46       1.1  atatat 
     47       1.1  atatat #include <err.h>
     48       1.1  atatat #include <kvm.h>
     49       1.1  atatat #include <stddef.h>
     50       1.1  atatat #include <stdlib.h>
     51       1.1  atatat 
     52       1.1  atatat #include <sys/types.h>
     53       1.1  atatat #include <sys/param.h>
     54       1.1  atatat #include <sys/time.h>
     55       1.1  atatat #include <sys/vnode.h>
     56       1.1  atatat #include <sys/mount.h>
     57       1.1  atatat #include <sys/uio.h>
     58       1.1  atatat #include <sys/namei.h>
     59       1.1  atatat #include <sys/sysctl.h>
     60       1.1  atatat 
     61       1.1  atatat #include <uvm/uvm.h>
     62       1.1  atatat #include <uvm/uvm_device.h>
     63       1.1  atatat 
     64       1.1  atatat #include <ufs/ufs/inode.h>
     65       1.1  atatat #undef doff_t
     66       1.1  atatat #undef IN_ACCESS
     67       1.1  atatat #include <isofs/cd9660/iso.h>
     68       1.1  atatat #include <isofs/cd9660/cd9660_node.h>
     69       1.1  atatat 
     70       1.1  atatat #define PMAP_HEADERS
     71       1.1  atatat #endif /* PMAP_HEADERS */
     72       1.1  atatat 
     73       1.1  atatat /*
     74       1.1  atatat  * if the definition of the kbit structure (and the accessor macros)
     75       1.1  atatat  * is already established, don't redefine it.
     76       1.1  atatat  */
     77       1.1  atatat #ifndef struct_kbit
     78       1.1  atatat 
     79       1.1  atatat /*
     80       1.1  atatat  * stolen (and munged) from #include <uvm/uvm_object.h>
     81       1.1  atatat  */
     82       1.1  atatat #define UVM_OBJ_IS_VNODE(uobj)    ((uobj)->pgops == uvm_vnodeops)
     83       1.1  atatat #define UVM_OBJ_IS_AOBJ(uobj)     ((uobj)->pgops == aobj_pager)
     84       1.1  atatat #define UVM_OBJ_IS_DEVICE(uobj)   ((uobj)->pgops == uvm_deviceops)
     85       1.1  atatat #define UVM_OBJ_IS_UBCPAGER(uobj) ((uobj)->pgops == ubc_pager)
     86       1.1  atatat 
     87       1.2  atatat /*
     88       1.2  atatat  * stolen from #include <uvm/uvm_amap.h>
     89       1.2  atatat  */
     90       1.2  atatat #define PPREF_NONE ((int *) -1)
     91       1.2  atatat 
     92       1.1  atatat /* the size of the object in the kernel */
     93       1.1  atatat #define S(x)	((x)->k_size)
     94       1.1  atatat /* the address of the object in kernel, two forms */
     95       1.1  atatat #define A(x)	((x)->k_addr.k_addr_ul)
     96       1.1  atatat #define P(x)	((x)->k_addr.k_addr_p)
     97       1.1  atatat /* the data from the kernel */
     98       1.1  atatat #define D(x,d)	(&((x)->k_data.d))
     99       1.1  atatat 
    100       1.1  atatat /* suck the data from the kernel */
    101       1.4  atatat #define _KDEREFOK(kd, addr, dst, sz) \
    102       1.4  atatat 	(kvm_read((kd), (addr), (dst), (sz)) == (sz))
    103       1.1  atatat #define _KDEREF(kd, addr, dst, sz) do { \
    104       1.4  atatat 	if (!_KDEREFOK((kd), (addr), (dst), (sz))) \
    105       1.1  atatat 		errx(1, "trying to read %lu bytes from %lx: %s", \
    106       1.1  atatat 		    (unsigned long)(sz), (addr), kvm_geterr(kd)); \
    107       1.1  atatat } while (0/*CONSTCOND*/)
    108       1.1  atatat 
    109       1.1  atatat /* suck the data using the structure */
    110       1.4  atatat #define KDEREFOK(kd, item) _KDEREFOK((kd), A(item), D(item, data), S(item))
    111       1.1  atatat #define KDEREF(kd, item) _KDEREF((kd), A(item), D(item, data), S(item))
    112       1.1  atatat 
    113       1.1  atatat struct kbit {
    114       1.1  atatat 	/*
    115       1.1  atatat 	 * size of data chunk
    116       1.1  atatat 	 */
    117       1.1  atatat 	size_t k_size;
    118       1.1  atatat 
    119       1.1  atatat 	/*
    120       1.1  atatat 	 * something for printf() and something for kvm_read()
    121       1.1  atatat 	 */
    122       1.1  atatat 	union {
    123       1.1  atatat 		void *k_addr_p;
    124       1.1  atatat 		u_long k_addr_ul;
    125       1.1  atatat 	} k_addr;
    126       1.1  atatat 
    127       1.1  atatat 	/*
    128       1.1  atatat 	 * where we actually put the "stuff"
    129       1.1  atatat 	 */
    130       1.1  atatat 	union {
    131       1.1  atatat 		char data[1];
    132       1.1  atatat 		struct vmspace vmspace;
    133       1.1  atatat 		struct vm_map vm_map;
    134       1.1  atatat 		struct vm_map_entry vm_map_entry;
    135       1.1  atatat 		struct vnode vnode;
    136       1.1  atatat 		struct uvm_object uvm_object;
    137       1.1  atatat 		struct mount mount;
    138       1.1  atatat 		struct namecache namecache;
    139       1.1  atatat 		struct inode inode;
    140       1.1  atatat 		struct iso_node iso_node;
    141       1.1  atatat 		struct uvm_device uvm_device;
    142       1.2  atatat 		struct vm_amap amap;
    143       1.2  atatat 		struct vm_anon anon;
    144       1.1  atatat 	} k_data;
    145       1.1  atatat };
    146       1.1  atatat #define struct_kbit
    147       1.1  atatat #endif /* struct_kbit */
    148       1.1  atatat 
    149       1.1  atatat /*
    150       1.1  atatat  * this is the *actual* module interface
    151       1.1  atatat  */
    152       1.3  atatat 
    153  1.5.18.1    matt void process_map(kvm_t *, struct kinfo_proc2 *,
    154       1.3  atatat 				   struct kbit *, const char *);
    155  1.5.18.1    matt void dump_vm_map(kvm_t *, struct kinfo_proc2 *,
    156       1.3  atatat 				   struct kbit *, struct kbit *, const char *);
    157  1.5.18.1    matt size_t dump_vm_map_entry(kvm_t *, struct kinfo_proc2 *,
    158       1.3  atatat 					   struct kbit *, struct kbit *, int);
    159  1.5.18.1    matt void dump_amap(kvm_t *, struct kbit *);
    160