The pc532 port now uses the new libkvm.

This commit is contained in:
matthias 1997-02-08 09:38:06 +00:00
parent 9712aaf1b5
commit d67f3db782
3 changed files with 49 additions and 63 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.26 1996/11/26 17:46:50 mrg Exp $
# $NetBSD: Makefile,v 1.27 1997/02/08 09:38:38 matthias Exp $
# from: @(#)Makefile 5.25.1.1 (Berkeley) 5/7/91
.include <bsd.own.mk> # for EXPORTABLE_SYSTEM definition
@ -11,6 +11,7 @@ SUBDIR= csu libarch libc libcompat libcrypt libcurses libedit libl \
.if (${MACHINE} == "alpha") || \
(${MACHINE} == "amiga") || \
(${MACHINE} == "atari") || \
(${MACHINE} == "pc532") || \
(${MACHINE} == "sparc") || \
(${MACHINE} == "sun3")
SUBDIR+= libkvm

View File

@ -1,4 +1,4 @@
/* $NetBSD: kvm_ns32k.c,v 1.4 1996/03/18 22:33:50 thorpej Exp $ */
/* $NetBSD: kvm_ns32k.c,v 1.5 1997/02/08 09:39:16 matthias Exp $ */
/*-
* Copyright (c) 1989, 1992, 1993
@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93";
#else
static char *rcsid = "$NetBSD: kvm_ns32k.c,v 1.4 1996/03/18 22:33:50 thorpej Exp $";
static char *rcsid = "$NetBSD: kvm_ns32k.c,v 1.5 1997/02/08 09:39:16 matthias Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@ -54,31 +54,31 @@ static char *rcsid = "$NetBSD: kvm_ns32k.c,v 1.4 1996/03/18 22:33:50 thorpej Exp
#include <sys/user.h>
#include <sys/proc.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <sys/core.h>
#include <sys/exec_aout.h>
#include <sys/kcore.h>
#include <unistd.h>
#include <limits.h>
#include <nlist.h>
#include <kvm.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <limits.h>
#include <db.h>
#include "kvm_private.h"
#include <machine/pte.h>
#include <machine/kcore.h>
#ifndef btop
#define btop(x) (((unsigned)(x)) >> PGSHIFT) /* XXX */
#define ptob(x) ((caddr_t)((x) << PGSHIFT)) /* XXX */
#endif
struct vmstate {
pd_entry_t **PTDpaddr;
pd_entry_t *PTD;
};
#define KREAD(kd, addr, p)\
(kvm_read(kd, addr, (char *)(p), sizeof(*(p))) != sizeof(*(p)))
@ -86,49 +86,14 @@ void
_kvm_freevtop(kd)
kvm_t *kd;
{
if (kd->vmst != 0) {
if (kd->vmst->PTD != 0)
free(kd->vmst->PTD);
if (kd->vmst != 0)
free(kd->vmst);
}
}
int
_kvm_initvtop(kd)
kvm_t *kd;
{
struct vmstate *vm;
struct nlist nlist[2];
pt_entry_t *tmpPTD;
vm = (struct vmstate *)_kvm_malloc(kd, sizeof(*vm));
if (vm == 0)
return (-1);
kd->vmst = vm;
nlist[0].n_name = "_PTDpaddr";
nlist[1].n_name = 0;
if (kvm_nlist(kd, nlist) != 0) {
_kvm_err(kd, kd->program, "bad namelist");
return (-1);
}
vm->PTDpaddr = 0;
vm->PTD = 0;
if (KREAD(kd, (u_long)nlist[0].n_value - KERNBASE, &vm->PTDpaddr)) {
_kvm_err(kd, kd->program, "cannot read PTDpaddr");
return (-1);
}
tmpPTD = (pd_entry_t *)_kvm_malloc(kd, NBPG);
if ((kvm_read(kd, (u_long)vm->PTDpaddr, tmpPTD, NBPG)) != NBPG) {
free(tmpPTD);
_kvm_err(kd, kd->program, "cannot read PTD");
return (-1);
}
vm->PTD = tmpPTD;
return (0);
}
@ -141,9 +106,11 @@ _kvm_kvatop(kd, va, pa)
u_long va;
u_long *pa;
{
struct vmstate *vm;
cpu_kcore_hdr_t *cpu_kh;
u_long offset;
u_long pte_pa;
u_long pde_pa;
pd_entry_t pde;
pt_entry_t pte;
if (ISALIVE(kd)) {
@ -151,32 +118,38 @@ _kvm_kvatop(kd, va, pa)
return(0);
}
vm = kd->vmst;
offset = va & PGOFSET;
cpu_kh = kd->cpu_data;
/*
* If we are initializing (kernel page table descriptor pointer
* not yet set) * then return pa == va to avoid infinite recursion.
*/
if (vm->PTD == 0) {
if (cpu_kh->ptd == 0) {
*pa = va;
return (NBPG - offset);
}
if ((vm->PTD[pdei(va)] & PG_V) == 0)
pde_pa = _kvm_pa2off(kd, cpu_kh->ptd + sizeof(pt_entry_t) * pdei(va));
if (lseek(kd->pmfd, (off_t)pde_pa, 0) == -1 && errno != 0) {
_kvm_syserr(kd, 0, "kvm_lseek");
goto invalid;
}
if (read(kd->pmfd, &pde, sizeof(pde)) != sizeof(pde)) {
_kvm_syserr(kd, kd->program, "kvm_read");
goto invalid;
}
if ((pde & PG_V) == 0)
goto invalid;
pte_pa = (vm->PTD[pdei(va)] & PG_FRAME) +
(ptei(va) * sizeof(pt_entry_t));
/* XXX READ PHYSICAL XXX */
{
if (lseek(kd->pmfd, (off_t)pte_pa, 0) == -1 && errno != 0) {
_kvm_syserr(kd, 0, "kvm_lseek");
goto invalid;
}
if (read(kd->pmfd, &pte, sizeof pte) != sizeof pte) {
_kvm_syserr(kd, kd->program, "kvm_read");
goto invalid;
}
pte_pa = _kvm_pa2off(kd, (pde & PG_FRAME) + sizeof(pt_entry_t) * ptei(va));
if (lseek(kd->pmfd, (off_t)pte_pa, 0) == -1 && errno != 0) {
_kvm_syserr(kd, 0, "kvm_lseek");
goto invalid;
}
if (read(kd->pmfd, &pte, sizeof pte) != sizeof pte) {
_kvm_syserr(kd, kd->program, "kvm_read");
goto invalid;
}
*pa = (pte & PG_FRAME) + offset;
@ -186,3 +159,14 @@ invalid:
_kvm_err(kd, 0, "invalid address (%x)", va);
return (0);
}
/*
* Translate a physical address to a file-offset in the crash-dump.
*/
off_t
_kvm_pa2off(kd, pa)
kvm_t *kd;
u_long pa;
{
return(kd->dump_off + pa);
}

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.13 1996/11/18 11:20:16 pk Exp $
# $NetBSD: Makefile,v 1.14 1997/02/08 09:38:06 matthias Exp $
# @(#)Makefile 8.2 (Berkeley) 4/17/94
PROG= savecore
@ -7,6 +7,7 @@ PROG= savecore
.if (${MACHINE} == "alpha") || \
(${MACHINE} == "amiga") || \
(${MACHINE} == "atari") || \
(${MACHINE} == "pc532") || \
(${MACHINE} == "sparc") || \
(${MACHINE} == "sun3")
SRCS= savecore.c