Annotation of sys/arch/amd64/amd64/kgdb_machdep.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: kgdb_machdep.c,v 1.1 2005/11/13 17:51:52 fgsch Exp $ */
! 2: /*
! 3: * Copyright (c) 2005 Federico G. Schwindt
! 4: *
! 5: * Redistribution and use in source and binary forms, with or without
! 6: * modification, are permitted provided that the following conditions
! 7: * are met:
! 8: * 1. Redistributions of source code must retain the above copyright
! 9: * notice, this list of conditions and the following disclaimer.
! 10: * 2. Redistributions in binary form must reproduce the above copyright
! 11: * notice, this list of conditions and the following disclaimer in the
! 12: * documentation and/or other materials provided with the distribution.
! 13: *
! 14: * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
! 15: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
! 16: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
! 17: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
! 18: * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
! 19: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
! 20: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 21: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 22: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 23: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
! 24: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 25: */
! 26:
! 27: #include <sys/kgdb.h>
! 28:
! 29: int
! 30: kgdb_acc(vaddr_t va, size_t len)
! 31: {
! 32: vaddr_t last_va;
! 33: pt_entry_t *pte;
! 34:
! 35: last_va = va + len;
! 36: va &= ~PGOFSET;
! 37: last_va &= PGOFSET;
! 38:
! 39: do {
! 40: pte = kvtopte(va);
! 41: if ((*pte & PG_V) == 0)
! 42: return (0);
! 43: va += NBPG;
! 44: } while (va < last_va);
! 45:
! 46: return (1);
! 47: }
! 48:
! 49: int
! 50: kgdb_signal(int type)
! 51: {
! 52: switch (type) {
! 53: default:
! 54: return (SIGEMT);
! 55: }
! 56: }
! 57:
! 58: void
! 59: kgdb_getregs(db_regs_t *regs, kgdb_reg_t *gdb_regs)
! 60: {
! 61: gdb_regs[ 0] = regs->tf_rax;
! 62: gdb_regs[ 1] = regs->tf_rbx;
! 63: gdb_regs[ 2] = regs->tf_rcx;
! 64: gdb_regs[ 3] = regs->tf_rdx;
! 65: gdb_regs[ 4] = regs->tf_rsi;
! 66: gdb_regs[ 5] = regs->tf_rdi;
! 67: gdb_regs[ 6] = regs->tf_rbp;
! 68: gdb_regs[ 7] = regs->tf_rsp;
! 69: gdb_regs[ 8] = regs->tf_r8;
! 70: gdb_regs[ 9] = regs->tf_r9;
! 71: gdb_regs[10] = regs->tf_r10;
! 72: gdb_regs[11] = regs->tf_r11;
! 73: gdb_regs[12] = regs->tf_r12;
! 74: gdb_regs[13] = regs->tf_r13;
! 75: gdb_regs[14] = regs->tf_r14;
! 76: gdb_regs[15] = regs->tf_r15;
! 77: gdb_regs[16] = regs->tf_rip;
! 78: /* XXX: 32bits but defined as 64 */
! 79: gdb_regs[17] = regs->tf_rflags;
! 80: gdb_regs[18] = regs->tf_cs;
! 81: gdb_regs[19] = regs->tf_ss;
! 82: }
! 83:
! 84: void
! 85: kgdb_setregs(db_regs_t *regs, kgdb_reg_t *gdb_regs)
! 86: {
! 87: regs->tf_rax = gdb_regs[ 0];
! 88: regs->tf_rbx = gdb_regs[ 1];
! 89: regs->tf_rcx = gdb_regs[ 2];
! 90: regs->tf_rdx = gdb_regs[ 3];
! 91: regs->tf_rsi = gdb_regs[ 4];
! 92: regs->tf_rdi = gdb_regs[ 5];
! 93: regs->tf_rbp = gdb_regs[ 6];
! 94: regs->tf_rsp = gdb_regs[ 7];
! 95: regs->tf_r8 = gdb_regs[ 8];
! 96: regs->tf_r9 = gdb_regs[ 9];
! 97: regs->tf_r10 = gdb_regs[10];
! 98: regs->tf_r11 = gdb_regs[11];
! 99: regs->tf_r12 = gdb_regs[12];
! 100: regs->tf_r13 = gdb_regs[13];
! 101: regs->tf_r14 = gdb_regs[14];
! 102: regs->tf_r15 = gdb_regs[15];
! 103: regs->tf_rip = gdb_regs[16];
! 104: regs->tf_rflags = gdb_regs[17];
! 105: regs->tf_cs = gdb_regs[18];
! 106: regs->tf_ss = gdb_regs[19];
! 107: }
CVSweb