11.10Schristos/*	$NetBSD: kvm_sh3.c,v 1.10 2022/01/10 19:51:30 christos Exp $	*/
21.1Smsaitoh
31.1Smsaitoh/*-
41.1Smsaitoh * Copyright (c) 1989, 1992, 1993
51.1Smsaitoh *	The Regents of the University of California.  All rights reserved.
61.1Smsaitoh *
71.1Smsaitoh * This code is derived from software developed by the Computer Systems
81.1Smsaitoh * Engineering group at Lawrence Berkeley Laboratory under DARPA contract
91.1Smsaitoh * BG 91-66 and contributed to Berkeley.
101.1Smsaitoh *
111.1Smsaitoh * Redistribution and use in source and binary forms, with or without
121.1Smsaitoh * modification, are permitted provided that the following conditions
131.1Smsaitoh * are met:
141.1Smsaitoh * 1. Redistributions of source code must retain the above copyright
151.1Smsaitoh *    notice, this list of conditions and the following disclaimer.
161.1Smsaitoh * 2. Redistributions in binary form must reproduce the above copyright
171.1Smsaitoh *    notice, this list of conditions and the following disclaimer in the
181.1Smsaitoh *    documentation and/or other materials provided with the distribution.
191.6Sagc * 3. Neither the name of the University nor the names of its contributors
201.1Smsaitoh *    may be used to endorse or promote products derived from this software
211.1Smsaitoh *    without specific prior written permission.
221.1Smsaitoh *
231.1Smsaitoh * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241.1Smsaitoh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251.1Smsaitoh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261.1Smsaitoh * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271.1Smsaitoh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281.1Smsaitoh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291.1Smsaitoh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.1Smsaitoh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.1Smsaitoh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.1Smsaitoh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.1Smsaitoh * SUCH DAMAGE.
341.1Smsaitoh */
351.1Smsaitoh
361.1Smsaitoh#include <sys/cdefs.h>
371.1Smsaitoh#if defined(LIBC_SCCS) && !defined(lint)
381.1Smsaitoh#if 0
391.1Smsaitohstatic char sccsid[] = "@(#)kvm_hp300.c	8.1 (Berkeley) 6/4/93";
401.1Smsaitoh#else
411.10Schristos__RCSID("$NetBSD: kvm_sh3.c,v 1.10 2022/01/10 19:51:30 christos Exp $");
421.1Smsaitoh#endif
431.1Smsaitoh#endif /* LIBC_SCCS and not lint */
441.1Smsaitoh
451.1Smsaitoh/*
461.5Sscw * SH3 machine dependent routines for kvm.
471.1Smsaitoh */
481.1Smsaitoh
491.1Smsaitoh#include <sys/param.h>
501.1Smsaitoh#include <sys/proc.h>
511.1Smsaitoh#include <sys/stat.h>
521.1Smsaitoh#include <sys/kcore.h>
531.8Sjym#include <sys/types.h>
541.8Sjym
551.1Smsaitoh#include <stdlib.h>
561.1Smsaitoh#include <unistd.h>
571.1Smsaitoh#include <nlist.h>
581.1Smsaitoh#include <kvm.h>
591.1Smsaitoh
601.3Smrg#include <uvm/uvm_extern.h>
611.1Smsaitoh
621.1Smsaitoh#include <limits.h>
631.1Smsaitoh#include <db.h>
641.1Smsaitoh
651.1Smsaitoh#include "kvm_private.h"
661.1Smsaitoh
671.1Smsaitoh#include <machine/pte.h>
681.4Smatt#include <machine/vmparam.h>
691.1Smsaitoh
701.1Smsaitoh#ifndef btop
711.1Smsaitoh#define	btop(x)		(((unsigned)(x)) >> PGSHIFT)	/* XXX */
721.1Smsaitoh#define	ptob(x)		((caddr_t)((x) << PGSHIFT))	/* XXX */
731.1Smsaitoh#endif
741.1Smsaitoh
751.1Smsaitohvoid
761.7Sjym_kvm_freevtop(kvm_t *kd)
771.1Smsaitoh{
781.1Smsaitoh
791.1Smsaitoh	/* Not actually used for anything right now, but safe. */
801.1Smsaitoh	if (kd->vmst != 0)
811.1Smsaitoh		free(kd->vmst);
821.1Smsaitoh}
831.1Smsaitoh
841.1Smsaitoh/*ARGSUSED*/
851.1Smsaitohint
861.7Sjym_kvm_initvtop(kvm_t *kd)
871.1Smsaitoh{
881.1Smsaitoh
891.1Smsaitoh	return (0);
901.1Smsaitoh}
911.1Smsaitoh
921.1Smsaitoh/*
931.1Smsaitoh * Translate a kernel virtual address to a physical address.
941.1Smsaitoh */
951.1Smsaitohint
961.8Sjym_kvm_kvatop(kvm_t *kd, vaddr_t va, paddr_t *pa)
971.1Smsaitoh{
981.1Smsaitoh	_kvm_err(kd, 0, "vatop not yet implemented!");
991.1Smsaitoh	return 0;
1001.1Smsaitoh}
1011.1Smsaitoh
1021.1Smsaitoh/*
1031.1Smsaitoh * Translate a physical address to a file-offset in the crash dump.
1041.1Smsaitoh */
1051.1Smsaitohoff_t
1061.8Sjym_kvm_pa2off(kvm_t *kd, paddr_t pa)
1071.1Smsaitoh{
1081.1Smsaitoh	_kvm_err(kd, 0, "pa2off not yet implemented!");
1091.1Smsaitoh	return 0;
1101.1Smsaitoh}
1111.1Smsaitoh
1121.1Smsaitoh/*
1131.1Smsaitoh * Machine-dependent initialization for ALL open kvm descriptors,
1141.1Smsaitoh * not just those for a kernel crash dump.  Some architectures
1151.1Smsaitoh * have to deal with these NOT being constants!  (i.e. m68k)
1161.1Smsaitoh */
1171.1Smsaitohint
1181.7Sjym_kvm_mdopen(kvm_t *kd)
1191.1Smsaitoh{
1201.1Smsaitoh
1211.1Smsaitoh	kd->min_uva = VM_MIN_ADDRESS;
1221.1Smsaitoh	kd->max_uva = VM_MAXUSER_ADDRESS;
1231.1Smsaitoh
1241.1Smsaitoh	return (0);
1251.1Smsaitoh}
126