alpha.c revision 1.1
11.1Sthorpej/* $NetBSD: alpha.c,v 1.1 2023/11/22 02:01:07 thorpej Exp $ */ 21.1Sthorpej 31.1Sthorpej/*- 41.1Sthorpej * Copyright (c) 2023 The NetBSD Foundation, Inc. 51.1Sthorpej * All rights reserved. 61.1Sthorpej * 71.1Sthorpej * This code is derived from software contributed to The NetBSD Foundation 81.1Sthorpej * by Jason R. Thorpe. 91.1Sthorpej * 101.1Sthorpej * Redistribution and use in source and binary forms, with or without 111.1Sthorpej * modification, are permitted provided that the following conditions 121.1Sthorpej * are met: 131.1Sthorpej * 1. Redistributions of source code must retain the above copyright 141.1Sthorpej * notice, this list of conditions and the following disclaimer. 151.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 161.1Sthorpej * notice, this list of conditions and the following disclaimer in the 171.1Sthorpej * documentation and/or other materials provided with the distribution. 181.1Sthorpej * 191.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Sthorpej * POSSIBILITY OF SUCH DAMAGE. 301.1Sthorpej */ 311.1Sthorpej 321.1Sthorpej#include <sys/cdefs.h> 331.1Sthorpej#ifndef lint 341.1Sthorpej__RCSID("$NetBSD: alpha.c,v 1.1 2023/11/22 02:01:07 thorpej Exp $"); 351.1Sthorpej#endif /* not lint */ 361.1Sthorpej 371.1Sthorpej#include <kvm.h> 381.1Sthorpej#include <nlist.h> 391.1Sthorpej#include <err.h> 401.1Sthorpej#include <stdlib.h> 411.1Sthorpej 421.1Sthorpej#include <ddb/ddb.h> 431.1Sthorpej 441.1Sthorpej#include <machine/frame.h> 451.1Sthorpej#include <machine/pcb.h> 461.1Sthorpej#include <alpha/db_machdep.h> 471.1Sthorpej 481.1Sthorpej#include "extern.h" 491.1Sthorpej 501.1Sthorpejstruct pcb pcb; 511.1Sthorpejstruct trapframe ddb_regs; 521.1Sthorpej 531.1Sthorpejextern db_alpha_nlist db_alpha_nl[]; 541.1Sthorpej 551.1Sthorpejvoid 561.1Sthorpejdb_mach_init(kvm_t *kd) 571.1Sthorpej{ 581.1Sthorpej 591.1Sthorpej if (kvm_nlist(kd, db_alpha_nl) == -1) { 601.1Sthorpej errx(EXIT_FAILURE, "kvm_nlist: %s", kvm_geterr(kd)); 611.1Sthorpej } 621.1Sthorpej if ((size_t)kvm_read(kd, db_alpha_nl[SYM_dumppcb].n_value, 631.1Sthorpej &pcb, sizeof(pcb)) != sizeof(pcb)) { 641.1Sthorpej warnx("cannot read dumppcb: %s", kvm_geterr(kd)); 651.1Sthorpej } 661.1Sthorpej 671.1Sthorpej memcpy(&ddb_regs.tf_regs[FRAME_S0], 681.1Sthorpej &pcb.pcb_context[0], 7 * sizeof(unsigned long)); 691.1Sthorpej ddb_regs.tf_regs[FRAME_RA] = pcb.pcb_context[7]; 701.1Sthorpej ddb_regs.tf_regs[FRAME_SP] = pcb.pcb_hw.apcb_ksp; 711.1Sthorpej ddb_regp = &ddb_regs; 721.1Sthorpej} 73