%x -> %lx format fixes from me.
-# $OpenBSD: Makefile,v 1.18 1997/02/26 03:06:48 downsj Exp $
+# $OpenBSD: Makefile,v 1.19 1997/02/26 16:46:25 niklas Exp $
# $NetBSD: Makefile,v 1.20.4.1 1996/06/14 17:22:38 cgd Exp $
SUBDIR= csu libarch libc libcom_err libcompat libcurses libedit \
liby libz
# XXX Temporarely until all ports are able to use libkvm (leo)
-.if (${MACHINE} == "amiga") || \
+.if (${MACHINE} == "alpha") || \
+ (${MACHINE} == "amiga") || \
(${MACHINE} == "atari") || \
(${MACHINE} == "powerpc") || \
(${MACHINE} == "sun3")
-/* $OpenBSD: kvm.c,v 1.5 1997/01/17 07:11:59 millert Exp $ */
+/* $OpenBSD: kvm.c,v 1.6 1997/02/26 16:46:28 niklas Exp $ */
/* $NetBSD: kvm.c,v 1.43 1996/05/05 04:31:59 gwr Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94";
#else
-static char *rcsid = "$OpenBSD: kvm.c,v 1.5 1997/01/17 07:11:59 millert Exp $";
+static char *rcsid = "$OpenBSD: kvm.c,v 1.6 1997/02/26 16:46:28 niklas Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
errno = 0;
if (lseek(kd->vmfd, (off_t)kva, SEEK_SET) == -1
&& errno != 0) {
- _kvm_err(kd, 0, "invalid address (%x)", kva);
+ _kvm_err(kd, 0, "invalid address (%lx)", kva);
return (0);
}
cc = read(kd->vmfd, buf, len);
errno = 0;
if (lseek(kd->vmfd, (off_t)kva, SEEK_SET) == -1
&& errno != 0) {
- _kvm_err(kd, 0, "invalid address (%x)", kva);
+ _kvm_err(kd, 0, "invalid address (%lx)", kva);
return (0);
}
cc = write(kd->vmfd, buf, len);
-/* $OpenBSD: kvm_alpha.c,v 1.2 1996/05/05 14:56:50 deraadt Exp $ */
-/* $NetBSD: kvm_alpha.c,v 1.2 1995/09/29 03:57:48 cgd Exp $ */
+/* $OpenBSD: kvm_alpha.c,v 1.3 1997/02/26 16:46:29 niklas Exp $ */
+/* $NetBSD: kvm_alpha.c,v 1.5 1996/10/01 21:12:05 cgd Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
#include <sys/user.h>
#include <sys/proc.h>
#include <sys/stat.h>
+#include <sys/kcore.h>
+#include <machine/kcore.h>
#include <unistd.h>
#include <nlist.h>
#include <kvm.h>
kvm_t *kd;
{
+ /* Not actually used for anything right now, but safe. */
+ if (kd->vmst != 0)
+ free(kd->vmst);
}
int
u_long va;
u_long *pa;
{
+ cpu_kcore_hdr_t *cpu_kh;
+ int rv, page_off;
+ alpha_pt_entry_t pte;
+ off_t pteoff;
- /* don't forget k0seg translations! */
+ if (ISALIVE(kd)) {
+ _kvm_err(kd, 0, "vatop called in live kernel!");
+ return(0);
+ }
- return (0);
+ cpu_kh = kd->cpu_data;
+ page_off = va & (cpu_kh->page_size - 1);
+
+ if (va >= ALPHA_K0SEG_BASE && va <= ALPHA_K0SEG_END) {
+ /*
+ * Direct-mapped address: just convert it.
+ */
+
+ *pa = ALPHA_K0SEG_TO_PHYS(va);
+ rv = cpu_kh->page_size - page_off;
+ } else if (va >= ALPHA_K1SEG_BASE && va <= ALPHA_K1SEG_END) {
+ /*
+ * Real kernel virtual address: do the translation.
+ */
+
+ /* Find and read the L1 PTE. */
+ pteoff = cpu_kh->lev1map_pa +
+ kvtol1pte(va) * sizeof(alpha_pt_entry_t);
+ if (lseek(kd->pmfd, _kvm_pa2off(kd, pteoff), 0) == -1 ||
+ read(kd->pmfd, (char *)&pte, sizeof(pte)) != sizeof(pte)) {
+ _kvm_syserr(kd, 0, "could not read L1 PTE");
+ goto lose;
+ }
+
+ /* Find and read the L2 PTE. */
+ if ((pte & ALPHA_PTE_VALID) == 0) {
+ _kvm_err(kd, 0, "invalid translation (invalid L1 PTE)");
+ goto lose;
+ }
+ pteoff = ALPHA_PTE_TO_PFN(pte) * cpu_kh->page_size +
+ vatoste(va) * sizeof(alpha_pt_entry_t);
+ if (lseek(kd->pmfd, _kvm_pa2off(kd, pteoff), 0) == -1 ||
+ read(kd->pmfd, (char *)&pte, sizeof(pte)) != sizeof(pte)) {
+ _kvm_syserr(kd, 0, "could not read L2 PTE");
+ goto lose;
+ }
+
+ /* Find and read the L3 PTE. */
+ if ((pte & ALPHA_PTE_VALID) == 0) {
+ _kvm_err(kd, 0, "invalid translation (invalid L2 PTE)");
+ goto lose;
+ }
+ pteoff = ALPHA_PTE_TO_PFN(pte) * cpu_kh->page_size +
+ vatopte(va) * sizeof(alpha_pt_entry_t);
+ if (lseek(kd->pmfd, _kvm_pa2off(kd, pteoff), 0) == -1 ||
+ read(kd->pmfd, (char *)&pte, sizeof(pte)) != sizeof(pte)) {
+ _kvm_syserr(kd, 0, "could not read L3 PTE");
+ goto lose;
+ }
+
+ /* Fill in the PA. */
+ if ((pte & ALPHA_PTE_VALID) == 0) {
+ _kvm_err(kd, 0, "invalid translation (invalid L3 PTE)");
+ goto lose;
+ }
+ *pa = ALPHA_PTE_TO_PFN(pte) * cpu_kh->page_size + page_off;
+ vatopte(va) * sizeof(alpha_pt_entry_t);
+ rv = cpu_kh->page_size - page_off;
+ } else {
+ /*
+ * Bogus address (not in KV space): punt.
+ */
+
+ _kvm_err(kd, 0, "invalid kernel virtual address");
+lose:
+ *pa = -1;
+ rv = 0;
+ }
+
+ return (rv);
+}
+
+/*
+ * Translate a physical address to a file-offset in the crash-dump.
+ */
+off_t
+_kvm_pa2off(kd, pa)
+ kvm_t *kd;
+ u_long pa;
+{
+ off_t off;
+ cpu_kcore_hdr_t *cpu_kh;
+
+ cpu_kh = kd->cpu_data;
+
+ off = 0;
+ pa -= cpu_kh->core_seg.start;
+
+ return (kd->dump_off + off + pa);
}
-/* $OpenBSD: kvm_arm32.c,v 1.1 1996/05/05 14:56:52 deraadt Exp $ */
+/* $OpenBSD: kvm_arm32.c,v 1.2 1997/02/26 16:46:29 niklas Exp $ */
/* $NetBSD: kvm_arm32.c,v 1.2 1996/03/18 22:33:16 thorpej Exp $ */
/*
#if 0
static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93";
#else
-static char *rcsid = "$OpenBSD: kvm_arm32.c,v 1.1 1996/05/05 14:56:52 deraadt Exp $";
+static char *rcsid = "$OpenBSD: kvm_arm32.c,v 1.2 1997/02/26 16:46:29 niklas Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
offset = va & PGOFSET;
invalid:
- _kvm_err(kd, 0, "invalid address (%x)", va);
+ _kvm_err(kd, 0, "invalid address (%lx)", va);
return (0);
}
return (NBPG - offset);
invalid:
- _kvm_err(kd, 0, "invalid address (%x)", va);
+ _kvm_err(kd, 0, "invalid address (%lx)", va);
return (0);
}
-/* $OpenBSD: kvm_i386.c,v 1.3 1996/05/05 14:57:20 deraadt Exp $ */
+/* $OpenBSD: kvm_i386.c,v 1.4 1997/02/26 16:46:30 niklas Exp $ */
/* $NetBSD: kvm_i386.c,v 1.9 1996/03/18 22:33:38 thorpej Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93";
#else
-static char *rcsid = "$OpenBSD: kvm_i386.c,v 1.3 1996/05/05 14:57:20 deraadt Exp $";
+static char *rcsid = "$OpenBSD: kvm_i386.c,v 1.4 1997/02/26 16:46:30 niklas Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
return (NBPG - offset);
invalid:
- _kvm_err(kd, 0, "invalid address (%x)", va);
+ _kvm_err(kd, 0, "invalid address (%lx)", va);
return (0);
}
-/* $OpenBSD: kvm_m68k.c,v 1.4 1996/05/10 12:58:31 deraadt Exp $ */
+/* $OpenBSD: kvm_m68k.c,v 1.5 1997/02/26 16:46:31 niklas Exp $ */
/* $NetBSD: kvm_m68k.c,v 1.9 1996/05/07 06:09:11 leo Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93";
#else
-static char *rcsid = "$OpenBSD: kvm_m68k.c,v 1.4 1996/05/10 12:58:31 deraadt Exp $";
+static char *rcsid = "$OpenBSD: kvm_m68k.c,v 1.5 1997/02/26 16:46:31 niklas Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
return (NBPG - offset);
invalid:
- _kvm_err(kd, 0, "invalid address (%x)", va);
+ _kvm_err(kd, 0, "invalid address (%lx)", va);
return (0);
}
-/* $OpenBSD: kvm_mips.c,v 1.3 1996/06/07 06:50:42 deraadt Exp $ */
+/* $OpenBSD: kvm_mips.c,v 1.4 1997/02/26 16:46:32 niklas Exp $ */
/* $NetBSD: kvm_mips.c,v 1.3 1996/03/18 22:33:44 thorpej Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)kvm_mips.c 8.1 (Berkeley) 6/4/93";
#else
-static char *rcsid = "$OpenBSD: kvm_mips.c,v 1.3 1996/06/07 06:50:42 deraadt Exp $";
+static char *rcsid = "$OpenBSD: kvm_mips.c,v 1.4 1997/02/26 16:46:32 niklas Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
return (NBPG - offset);
invalid:
- _kvm_err(kd, 0, "invalid address (%x)", va);
+ _kvm_err(kd, 0, "invalid address (%lx)", va);
return (0);
}
-/* $OpenBSD: kvm_ns32k.c,v 1.2 1996/05/05 14:57:32 deraadt Exp $ */
+/* $OpenBSD: kvm_ns32k.c,v 1.3 1997/02/26 16:46:32 niklas Exp $ */
/* $NetBSD: kvm_ns32k.c,v 1.4 1996/03/18 22:33:50 thorpej Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93";
#else
-static char *rcsid = "$OpenBSD: kvm_ns32k.c,v 1.2 1996/05/05 14:57:32 deraadt Exp $";
+static char *rcsid = "$OpenBSD: kvm_ns32k.c,v 1.3 1997/02/26 16:46:32 niklas Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
return (NBPG - offset);
invalid:
- _kvm_err(kd, 0, "invalid address (%x)", va);
+ _kvm_err(kd, 0, "invalid address (%lx)", va);
return (0);
}
-/* $OpenBSD: kvm_proc.c,v 1.3 1996/10/23 16:43:08 deraadt Exp $ */
+/* $OpenBSD: kvm_proc.c,v 1.4 1997/02/26 16:46:33 niklas Exp $ */
/* $NetBSD: kvm_proc.c,v 1.16 1996/03/18 22:33:57 thorpej Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93";
#else
-static char *rcsid = "$OpenBSD: kvm_proc.c,v 1.3 1996/10/23 16:43:08 deraadt Exp $";
+static char *rcsid = "$OpenBSD: kvm_proc.c,v 1.4 1997/02/26 16:46:33 niklas Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
* Pointers are stored at the top of the user stack.
*/
if (p->p_stat == SZOMB ||
- kvm_uread(kd, p, ps, (char *)&arginfo,
+ kvm_uread(kd, p, (u_long)ps, (char *)&arginfo,
sizeof(arginfo)) != sizeof(arginfo))
return (0);
dp = _kvm_uread(kd, p, uva, &cnt);
if (dp == 0) {
- _kvm_err(kd, 0, "invalid address (%x)", uva);
+ _kvm_err(kd, 0, "invalid address (%lx)", uva);
return (0);
}
cc = MIN(cnt, len);
-/* $OpenBSD: kvm_sparc.c,v 1.2 1996/05/05 14:57:50 deraadt Exp $ */
+/* $OpenBSD: kvm_sparc.c,v 1.3 1997/02/26 16:46:34 niklas Exp $ */
/* $NetBSD: kvm_sparc.c,v 1.9 1996/04/01 19:23:03 cgd Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)kvm_sparc.c 8.1 (Berkeley) 6/4/93";
#else
-static char *rcsid = "$OpenBSD: kvm_sparc.c,v 1.2 1996/05/05 14:57:50 deraadt Exp $";
+static char *rcsid = "$OpenBSD: kvm_sparc.c,v 1.3 1997/02/26 16:46:34 niklas Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
return (kd->nbpg - off);
}
err:
- _kvm_err(kd, 0, "invalid address (%x)", va);
+ _kvm_err(kd, 0, "invalid address (%lx)", va);
return (0);
}
return (kd->nbpg - off);
}
err:
- _kvm_err(kd, 0, "invalid address (%x)", va);
+ _kvm_err(kd, 0, "invalid address (%lx)", va);
return (0);
}
-/* $OpenBSD: kvm_vax.c,v 1.2 1996/05/05 14:57:57 deraadt Exp $ */
+/* $OpenBSD: kvm_vax.c,v 1.3 1997/02/26 16:46:35 niklas Exp $ */
/* $NetBSD: kvm_vax.c,v 1.3 1996/03/18 22:34:06 thorpej Exp $ */
/*-
u_long va;
u_long *pa;
{
- register int end;
+ register u_long end;
if (va < KERNBASE) {
- _kvm_err(kd, 0, "invalid address (%x<%x)", va, KERNBASE);
+ _kvm_err(kd, 0, "invalid address (%lx<%lx)", va, KERNBASE);
return (0);
}
end = kd->vmst->end;
if (va >= end) {
- _kvm_err(kd, 0, "invalid address (%x>=%x)", va, end);
+ _kvm_err(kd, 0, "invalid address (%lx>=%lx)", va, end);
return (0);
}