kgdb_glue.c revision 1.1.8.1 1 1.1.8.1 yamt /* $NetBSD: kgdb_glue.c,v 1.1.8.1 2007/10/18 08:32:41 yamt Exp $ */
2 1.1.8.1 yamt
3 1.1.8.1 yamt /*
4 1.1.8.1 yamt * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 1.1.8.1 yamt * Copyright (C) 1995, 1996 TooLs GmbH.
6 1.1.8.1 yamt * All rights reserved.
7 1.1.8.1 yamt *
8 1.1.8.1 yamt * Redistribution and use in source and binary forms, with or without
9 1.1.8.1 yamt * modification, are permitted provided that the following conditions
10 1.1.8.1 yamt * are met:
11 1.1.8.1 yamt * 1. Redistributions of source code must retain the above copyright
12 1.1.8.1 yamt * notice, this list of conditions and the following disclaimer.
13 1.1.8.1 yamt * 2. Redistributions in binary form must reproduce the above copyright
14 1.1.8.1 yamt * notice, this list of conditions and the following disclaimer in the
15 1.1.8.1 yamt * documentation and/or other materials provided with the distribution.
16 1.1.8.1 yamt * 3. All advertising materials mentioning features or use of this software
17 1.1.8.1 yamt * must display the following acknowledgement:
18 1.1.8.1 yamt * This product includes software developed by TooLs GmbH.
19 1.1.8.1 yamt * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 1.1.8.1 yamt * derived from this software without specific prior written permission.
21 1.1.8.1 yamt *
22 1.1.8.1 yamt * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 1.1.8.1 yamt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1.8.1 yamt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1.8.1 yamt * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 1.1.8.1 yamt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 1.1.8.1 yamt * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 1.1.8.1 yamt * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 1.1.8.1 yamt * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 1.1.8.1 yamt * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 1.1.8.1 yamt * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1.8.1 yamt */
33 1.1.8.1 yamt
34 1.1.8.1 yamt #include <sys/cdefs.h>
35 1.1.8.1 yamt __KERNEL_RCSID(0, "$NetBSD: kgdb_glue.c,v 1.1.8.1 2007/10/18 08:32:41 yamt Exp $");
36 1.1.8.1 yamt
37 1.1.8.1 yamt #include <sys/param.h>
38 1.1.8.1 yamt
39 1.1.8.1 yamt #include <kgdb/kgdb.h>
40 1.1.8.1 yamt
41 1.1.8.1 yamt #include <machine/frame.h>
42 1.1.8.1 yamt #include <machine/kgdb.h>
43 1.1.8.1 yamt #include <machine/pcb.h>
44 1.1.8.1 yamt #include <machine/psl.h>
45 1.1.8.1 yamt #include <machine/trap.h>
46 1.1.8.1 yamt
47 1.1.8.1 yamt int kgdbregs[NREG];
48 1.1.8.1 yamt
49 1.1.8.1 yamt #ifdef KGDBUSERHACK
50 1.1.8.1 yamt int kgdbsr; /* TEMPRORARY (Really needs some better mechanism) XXX */
51 1.1.8.1 yamt int savesr;
52 1.1.8.1 yamt #endif
53 1.1.8.1 yamt
54 1.1.8.1 yamt void
55 1.1.8.1 yamt kgdbinit()
56 1.1.8.1 yamt {
57 1.1.8.1 yamt }
58 1.1.8.1 yamt
59 1.1.8.1 yamt int
60 1.1.8.1 yamt kgdb_poll()
61 1.1.8.1 yamt {
62 1.1.8.1 yamt /* for now: */
63 1.1.8.1 yamt return 0;
64 1.1.8.1 yamt }
65 1.1.8.1 yamt
66 1.1.8.1 yamt int
67 1.1.8.1 yamt kgdb_trap_glue(struct trapframe *frame)
68 1.1.8.1 yamt {
69 1.1.8.1 yamt if (!(frame->srr1 & PSL_PR)
70 1.1.8.1 yamt && (frame->exc == EXC_TRC
71 1.1.8.1 yamt || (frame->exc == EXC_PGM
72 1.1.8.1 yamt && (frame->srr1 & 0x20000))
73 1.1.8.1 yamt || frame->exc == EXC_BPT)) {
74 1.1.8.1 yamt #ifdef KGDBUSERHACK
75 1.1.8.1 yamt __asm ("mfsr %0,%1" : "=r"(savesr) : "K"(USER_SR)); /* see above XXX */
76 1.1.8.1 yamt #endif
77 1.1.8.1 yamt kgdbcopy(frame, kgdbregs, sizeof kgdbregs);
78 1.1.8.1 yamt kgdbregs[MSR] &= ~PSL_BE;
79 1.1.8.1 yamt
80 1.1.8.1 yamt switch (kgdbcmds()) {
81 1.1.8.1 yamt case 2:
82 1.1.8.1 yamt case 0:
83 1.1.8.1 yamt kgdbregs[MSR] &= ~PSL_SE;
84 1.1.8.1 yamt break;
85 1.1.8.1 yamt case 1:
86 1.1.8.1 yamt kgdbregs[MSR] |= PSL_SE;
87 1.1.8.1 yamt break;
88 1.1.8.1 yamt }
89 1.1.8.1 yamt kgdbcopy(kgdbregs, frame, sizeof kgdbregs);
90 1.1.8.1 yamt #ifdef KGDBUSERHACK
91 1.1.8.1 yamt __asm ("mtsr %0,%1; isync" :: "K"(USER_SR), "r"(savesr));
92 1.1.8.1 yamt #endif
93 1.1.8.1 yamt return 1;
94 1.1.8.1 yamt }
95 1.1.8.1 yamt return 0;
96 1.1.8.1 yamt }
97