1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * kdebug.h: Defines and definitions for debugging the Linux kernel 4*4882a593Smuzhiyun * under various kernel debuggers. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 7*4882a593Smuzhiyun */ 8*4882a593Smuzhiyun #ifndef _SPARC_KDEBUG_H 9*4882a593Smuzhiyun #define _SPARC_KDEBUG_H 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #include <asm/openprom.h> 12*4882a593Smuzhiyun #include <asm/vaddrs.h> 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun /* Breakpoints are enter through trap table entry 126. So in sparc assembly 15*4882a593Smuzhiyun * if you want to drop into the debugger you do: 16*4882a593Smuzhiyun * 17*4882a593Smuzhiyun * t DEBUG_BP_TRAP 18*4882a593Smuzhiyun */ 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun #define DEBUG_BP_TRAP 126 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun #ifndef __ASSEMBLY__ 23*4882a593Smuzhiyun /* The debug vector is passed in %o1 at boot time. It is a pointer to 24*4882a593Smuzhiyun * a structure in the debuggers address space. Here is its format. 25*4882a593Smuzhiyun */ 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun typedef unsigned int (*debugger_funct)(void); 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun struct kernel_debug { 30*4882a593Smuzhiyun /* First the entry point into the debugger. You jump here 31*4882a593Smuzhiyun * to give control over to the debugger. 32*4882a593Smuzhiyun */ 33*4882a593Smuzhiyun unsigned long kdebug_entry; 34*4882a593Smuzhiyun unsigned long kdebug_trapme; /* Figure out later... */ 35*4882a593Smuzhiyun /* The following is the number of pages that the debugger has 36*4882a593Smuzhiyun * taken from to total pool. 37*4882a593Smuzhiyun */ 38*4882a593Smuzhiyun unsigned long *kdebug_stolen_pages; 39*4882a593Smuzhiyun /* Ok, after you remap yourself and/or change the trap table 40*4882a593Smuzhiyun * from what you were left with at boot time you have to call 41*4882a593Smuzhiyun * this synchronization function so the debugger can check out 42*4882a593Smuzhiyun * what you have done. 43*4882a593Smuzhiyun */ 44*4882a593Smuzhiyun debugger_funct teach_debugger; 45*4882a593Smuzhiyun }; /* I think that is it... */ 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun extern struct kernel_debug *linux_dbvec; 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun /* Use this macro in C-code to enter the debugger. */ sp_enter_debugger(void)50*4882a593Smuzhiyunstatic inline void sp_enter_debugger(void) 51*4882a593Smuzhiyun { 52*4882a593Smuzhiyun __asm__ __volatile__("jmpl %0, %%o7\n\t" 53*4882a593Smuzhiyun "nop\n\t" : : 54*4882a593Smuzhiyun "r" (linux_dbvec) : "o7", "memory"); 55*4882a593Smuzhiyun } 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun #define SP_ENTER_DEBUGGER do { \ 58*4882a593Smuzhiyun if((linux_dbvec!=0) && ((*(short *)linux_dbvec)!=-1)) \ 59*4882a593Smuzhiyun sp_enter_debugger(); \ 60*4882a593Smuzhiyun } while(0) 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun enum die_val { 63*4882a593Smuzhiyun DIE_UNUSED, 64*4882a593Smuzhiyun DIE_OOPS, 65*4882a593Smuzhiyun }; 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun #endif /* !(__ASSEMBLY__) */ 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun /* Some nice offset defines for assembler code. */ 70*4882a593Smuzhiyun #define KDEBUG_ENTRY_OFF 0x0 71*4882a593Smuzhiyun #define KDEBUG_DUNNO_OFF 0x4 72*4882a593Smuzhiyun #define KDEBUG_DUNNO2_OFF 0x8 73*4882a593Smuzhiyun #define KDEBUG_TEACH_OFF 0xc 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun #endif /* !(_SPARC_KDEBUG_H) */ 76