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