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