kvm_private.h revision 1856
155682Smarkm/*-
2233294Sstas * Copyright (c) 1992, 1993
3233294Sstas *	The Regents of the University of California.  All rights reserved.
4233294Sstas *
555682Smarkm * This code is derived from software developed by the Computer Systems
6233294Sstas * Engineering group at Lawrence Berkeley Laboratory under DARPA contract
7233294Sstas * BG 91-66 and contributed to Berkeley.
8233294Sstas *
955682Smarkm * Redistribution and use in source and binary forms, with or without
10233294Sstas * modification, are permitted provided that the following conditions
11233294Sstas * are met:
1255682Smarkm * 1. Redistributions of source code must retain the above copyright
13233294Sstas *    notice, this list of conditions and the following disclaimer.
14233294Sstas * 2. Redistributions in binary form must reproduce the above copyright
15233294Sstas *    notice, this list of conditions and the following disclaimer in the
1655682Smarkm *    documentation and/or other materials provided with the distribution.
17233294Sstas * 3. All advertising materials mentioning features or use of this software
18233294Sstas *    must display the following acknowledgement:
19233294Sstas *	This product includes software developed by the University of
2055682Smarkm *	California, Berkeley and its contributors.
21233294Sstas * 4. Neither the name of the University nor the names of its contributors
22233294Sstas *    may be used to endorse or promote products derived from this software
23233294Sstas *    without specific prior written permission.
24233294Sstas *
25233294Sstas * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26233294Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27233294Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28233294Sstas * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29233294Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30233294Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31233294Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3255682Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3355682Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3455682Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3555682Smarkm * SUCH DAMAGE.
3690926Snectar *
3790926Snectar *	@(#)kvm_private.h	8.1 (Berkeley) 6/4/93
3890926Snectar */
3990926Snectar
4090926Snectarstruct __kvm {
4190926Snectar	/*
4290926Snectar	 * a string to be prepended to error messages
4390926Snectar	 * provided for compatibility with sun's interface
4490926Snectar	 * if this value is null, errors are saved in errbuf[]
4590926Snectar	 */
4690926Snectar	const char *program;
4790926Snectar	char	*errp;		/* XXX this can probably go away */
4890926Snectar	char	errbuf[_POSIX2_LINE_MAX];
4990926Snectar	DB	*db;
5090926Snectar#define ISALIVE(kd) ((kd)->vmfd >= 0)
5190926Snectar	int	pmfd;		/* physical memory file (or crashdump) */
5290926Snectar	int	vmfd;		/* virtual memory file (-1 if crashdump) */
5390926Snectar	int	swfd;		/* swap file (e.g., /dev/drum) */
5455682Smarkm	int	nlfd;		/* namelist file (e.g., /kernel) */
5555682Smarkm	struct kinfo_proc *procbase;
5655682Smarkm	char	*argspc;	/* (dynamic) storage for argv strings */
5755682Smarkm	int	arglen;		/* length of the above */
5855682Smarkm	char	**argv;		/* (dynamic) storage for argv pointers */
5955682Smarkm	int	argc;		/* length of above (not actual # present) */
6055682Smarkm	/*
61178825Sdfr	 * Kernel virtual address translation state.  This only gets filled
6255682Smarkm	 * in for dead kernels; otherwise, the running kernel (i.e. kmem)
63178825Sdfr	 * will do the translations for us.  It could be big, so we
64178825Sdfr	 * only allocate it if necessary.
6555682Smarkm	 */
6690926Snectar	struct vmstate *vmst;
6790926Snectar};
68178825Sdfr
6990926Snectar/*
70233294Sstas * Functions used internally by kvm, but across kvm modules.
7190926Snectar */
7290926Snectarvoid	 _kvm_err __P((kvm_t *kd, const char *program, const char *fmt, ...));
7390926Snectarvoid	 _kvm_freeprocs __P((kvm_t *kd));
7490926Snectarvoid	 _kvm_freevtop __P((kvm_t *));
7590926Snectarint	 _kvm_initvtop __P((kvm_t *));
7690926Snectarint	 _kvm_kvatop __P((kvm_t *, u_long, u_long *));
7790926Snectarvoid	*_kvm_malloc __P((kvm_t *kd, size_t));
78233294Sstasvoid	*_kvm_realloc __P((kvm_t *kd, void *, size_t));
79178825Sdfrvoid	 _kvm_syserr
80178825Sdfr	    __P((kvm_t *kd, const char *program, const char *fmt, ...));
8190926Snectarint	 _kvm_uvatop __P((kvm_t *, const struct proc *, u_long, u_long *));
8272445Sassar