···11+ A Simple Guide to Configure KGDB22+33+ Sonic Zhang <sonic.zhang@analog.com>44+ Aug. 24th 200655+66+77+This KGDB patch enables the kernel developer to do source level debugging on88+the kernel for the Blackfin architecture. The debugging works over either the99+ethernet interface or one of the uarts. Both software breakpoints and1010+hardware breakpoints are supported in this version.1111+http://docs.blackfin.uclinux.org/doku.php?id=kgdb1212+1313+1414+2 known issues:1515+1. This bug:1616+ http://blackfin.uclinux.org/tracker/index.php?func=detail&aid=544&group_id=18&atid=1451717+ The GDB client for Blackfin uClinux causes incorrect values of local1818+ variables to be displayed when the user breaks the running of kernel in GDB.1919+2. Because of a hardware bug in Blackfin 533 v1.0.3:2020+ 05000067 - Watchpoints (Hardware Breakpoints) are not supported2121+ Hardware breakpoints cannot be set properly.2222+2323+2424+Debug over Ethernet:2525+2626+1. Compile and install the cross platform version of gdb for blackfin, which2727+ can be found at $(BINROOT)/bfin-elf-gdb.2828+2929+2. Apply this patch to the 2.6.x kernel. Select the menuconfig option under3030+ "Kernel hacking" -> "Kernel debugging" -> "KGDB: kernel debug with remote gdb".3131+ With this selected, option "Full Symbolic/Source Debugging support" and 3232+ "Compile the kernel with frame pointers" are also selected.3333+3434+3. Select option "KGDB: connect over (Ethernet)". Add "kgdboe=@target-IP/,@host-IP/" to3535+ the option "Compiled-in Kernel Boot Parameter" under "Kernel hacking".3636+3737+4. Connect minicom to the serial port and boot the kernel image.3838+3939+5. Configure the IP "/> ifconfig eth0 target-IP"4040+4141+6. Start GDB client "bfin-elf-gdb vmlinux".4242+4343+7. Connect to the target "(gdb) target remote udp:target-IP:6443".4444+4545+8. Set software breakpoint "(gdb) break sys_open".4646+4747+9. Continue "(gdb) c".4848+4949+10. Run ls in the target console "/> ls".5050+5151+11. Breakpoint hits. "Breakpoint 1: sys_open(..."5252+5353+12. Display local variables and function paramters.5454+ (*) This operation gives wrong results, see known issue 1.5555+5656+13. Single stepping "(gdb) si".5757+5858+14. Remove breakpoint 1. "(gdb) del 1"5959+6060+15. Set hardware breakpoint "(gdb) hbreak sys_open".6161+6262+16. Continue "(gdb) c".6363+6464+17. Run ls in the target console "/> ls".6565+6666+18. Hardware breakpoint hits. "Breakpoint 1: sys_open(...".6767+ (*) This hardware breakpoint will not be hit, see known issue 2.6868+6969+19. Continue "(gdb) c".7070+7171+20. Interrupt the target in GDB "Ctrl+C".7272+7373+21. Detach from the target "(gdb) detach".7474+7575+22. Exit GDB "(gdb) quit".7676+7777+7878+Debug over the UART:7979+8080+1. Compile and install the cross platform version of gdb for blackfin, which8181+ can be found at $(BINROOT)/bfin-elf-gdb.8282+8383+2. Apply this patch to the 2.6.x kernel. Select the menuconfig option under8484+ "Kernel hacking" -> "Kernel debugging" -> "KGDB: kernel debug with remote gdb".8585+ With this selected, option "Full Symbolic/Source Debugging support" and 8686+ "Compile the kernel with frame pointers" are also selected.8787+8888+3. Select option "KGDB: connect over (UART)". Set "KGDB: UART port number" to be8989+ a different one from the console. Don't forget to change the mode of9090+ blackfin serial driver to PIO. Otherwise kgdb works incorrectly on UART.9191+9292+4. If you want connect to kgdb when the kernel boots, enable9393+ "KGDB: Wait for gdb connection early" 9494+9595+5. Compile kernel.9696+9797+6. Connect minicom to the serial port of the console and boot the kernel image.9898+9999+7. Start GDB client "bfin-elf-gdb vmlinux".100100+101101+8. Set the baud rate in GDB "(gdb) set remotebaud 57600".102102+103103+9. Connect to the target on the second serial port "(gdb) target remote /dev/ttyS1".104104+105105+10. Set software breakpoint "(gdb) break sys_open".106106+107107+11. Continue "(gdb) c". 108108+109109+12. Run ls in the target console "/> ls". 110110+111111+13. A breakpoint is hit. "Breakpoint 1: sys_open(..."112112+113113+14. All other operations are the same as that in KGDB over Ethernet. 114114+115115+116116+Debug over the same UART as console:117117+118118+1. Compile and install the cross platform version of gdb for blackfin, which119119+ can be found at $(BINROOT)/bfin-elf-gdb.120120+121121+2. Apply this patch to the 2.6.x kernel. Select the menuconfig option under122122+ "Kernel hacking" -> "Kernel debugging" -> "KGDB: kernel debug with remote gdb".123123+ With this selected, option "Full Symbolic/Source Debugging support" and 124124+ "Compile the kernel with frame pointers" are also selected.125125+126126+3. Select option "KGDB: connect over UART". Set "KGDB: UART port number" to console.127127+ Don't forget to change the mode of blackfin serial driver to PIO.128128+ Otherwise kgdb works incorrectly on UART.129129+130130+4. If you want connect to kgdb when the kernel boots, enable131131+ "KGDB: Wait for gdb connection early" 132132+133133+5. Connect minicom to the serial port and boot the kernel image. 134134+135135+6. (Optional) Ask target to wait for gdb connection by entering Ctrl+A. In minicom, you should enter Ctrl+A+A.136136+137137+7. Start GDB client "bfin-elf-gdb vmlinux".138138+139139+8. Set the baud rate in GDB "(gdb) set remotebaud 57600".140140+141141+9. Connect to the target "(gdb) target remote /dev/ttyS0".142142+143143+10. Set software breakpoint "(gdb) break sys_open".144144+145145+11. Continue "(gdb) c". Then enter Ctrl+C twice to stop GDB connection.146146+147147+12. Run ls in the target console "/> ls". Dummy string can be seen on the console.148148+149149+13. Then connect the gdb to target again. "(gdb) target remote /dev/ttyS0".150150+ Now you will find a breakpoint is hit. "Breakpoint 1: sys_open(..."151151+152152+14. All other operations are the same as that in KGDB over Ethernet. The only153153+ difference is that after continue command in GDB, please stop GDB154154+ connection by 2 "Ctrl+C"s and connect again after breakpoints are hit or155155+ Ctrl+A is entered.
···11+/*22+ * File: arch/blackfin/kernel/kgdb.c33+ * Based on:44+ * Author: Sonic Zhang55+ *66+ * Created:77+ * Description:88+ *99+ * Rev: $Id: kgdb_bfin_linux-2.6.x.patch 4934 2007-02-13 09:32:11Z sonicz $1010+ *1111+ * Modified:1212+ * Copyright 2005-2006 Analog Devices Inc.1313+ *1414+ * Bugs: Enter bugs at http://blackfin.uclinux.org/1515+ *1616+ * This program is free software; you can redistribute it and/or modify1717+ * it under the terms of the GNU General Public License as published by1818+ * the Free Software Foundation; either version 2 of the License, or1919+ * (at your option) any later version.2020+ *2121+ * This program is distributed in the hope that it will be useful,2222+ * but WITHOUT ANY WARRANTY; without even the implied warranty of2323+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2424+ * GNU General Public License for more details.2525+ *2626+ * You should have received a copy of the GNU General Public License2727+ * along with this program; if not, see the file COPYING, or write2828+ * to the Free Software Foundation, Inc.,2929+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA3030+ */3131+3232+#include <linux/string.h>3333+#include <linux/kernel.h>3434+#include <linux/sched.h>3535+#include <linux/smp.h>3636+#include <linux/spinlock.h>3737+#include <linux/delay.h>3838+#include <linux/ptrace.h> /* for linux pt_regs struct */3939+#include <linux/kgdb.h>4040+#include <linux/console.h>4141+#include <linux/init.h>4242+#include <linux/debugger.h>4343+#include <linux/errno.h>4444+#include <linux/irq.h>4545+#include <asm/system.h>4646+#include <asm/traps.h>4747+#include <asm/blackfin.h>4848+4949+/* Put the error code here just in case the user cares. */5050+int gdb_bf533errcode;5151+/* Likewise, the vector number here (since GDB only gets the signal5252+ number through the usual means, and that's not very specific). */5353+int gdb_bf533vector = -1;5454+5555+#if KGDB_MAX_NO_CPUS != 85656+#error change the definition of slavecpulocks5757+#endif5858+5959+void regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)6060+{6161+ gdb_regs[BFIN_R0] = regs->r0;6262+ gdb_regs[BFIN_R1] = regs->r1;6363+ gdb_regs[BFIN_R2] = regs->r2;6464+ gdb_regs[BFIN_R3] = regs->r3;6565+ gdb_regs[BFIN_R4] = regs->r4;6666+ gdb_regs[BFIN_R5] = regs->r5;6767+ gdb_regs[BFIN_R6] = regs->r6;6868+ gdb_regs[BFIN_R7] = regs->r7;6969+ gdb_regs[BFIN_P0] = regs->p0;7070+ gdb_regs[BFIN_P1] = regs->p1;7171+ gdb_regs[BFIN_P2] = regs->p2;7272+ gdb_regs[BFIN_P3] = regs->p3;7373+ gdb_regs[BFIN_P4] = regs->p4;7474+ gdb_regs[BFIN_P5] = regs->p5;7575+ gdb_regs[BFIN_SP] = regs->reserved;7676+ gdb_regs[BFIN_FP] = regs->fp;7777+ gdb_regs[BFIN_I0] = regs->i0;7878+ gdb_regs[BFIN_I1] = regs->i1;7979+ gdb_regs[BFIN_I2] = regs->i2;8080+ gdb_regs[BFIN_I3] = regs->i3;8181+ gdb_regs[BFIN_M0] = regs->m0;8282+ gdb_regs[BFIN_M1] = regs->m1;8383+ gdb_regs[BFIN_M2] = regs->m2;8484+ gdb_regs[BFIN_M3] = regs->m3;8585+ gdb_regs[BFIN_B0] = regs->b0;8686+ gdb_regs[BFIN_B1] = regs->b1;8787+ gdb_regs[BFIN_B2] = regs->b2;8888+ gdb_regs[BFIN_B3] = regs->b3;8989+ gdb_regs[BFIN_L0] = regs->l0;9090+ gdb_regs[BFIN_L1] = regs->l1;9191+ gdb_regs[BFIN_L2] = regs->l2;9292+ gdb_regs[BFIN_L3] = regs->l3;9393+ gdb_regs[BFIN_A0_DOT_X] = regs->a0x;9494+ gdb_regs[BFIN_A0_DOT_W] = regs->a0w;9595+ gdb_regs[BFIN_A1_DOT_X] = regs->a1x;9696+ gdb_regs[BFIN_A1_DOT_W] = regs->a1w;9797+ gdb_regs[BFIN_ASTAT] = regs->astat;9898+ gdb_regs[BFIN_RETS] = regs->rets;9999+ gdb_regs[BFIN_LC0] = regs->lc0;100100+ gdb_regs[BFIN_LT0] = regs->lt0;101101+ gdb_regs[BFIN_LB0] = regs->lb0;102102+ gdb_regs[BFIN_LC1] = regs->lc1;103103+ gdb_regs[BFIN_LT1] = regs->lt1;104104+ gdb_regs[BFIN_LB1] = regs->lb1;105105+ gdb_regs[BFIN_CYCLES] = 0;106106+ gdb_regs[BFIN_CYCLES2] = 0;107107+ gdb_regs[BFIN_USP] = regs->usp;108108+ gdb_regs[BFIN_SEQSTAT] = regs->seqstat;109109+ gdb_regs[BFIN_SYSCFG] = regs->syscfg;110110+ gdb_regs[BFIN_RETI] = regs->pc;111111+ gdb_regs[BFIN_RETX] = regs->retx;112112+ gdb_regs[BFIN_RETN] = regs->retn;113113+ gdb_regs[BFIN_RETE] = regs->rete;114114+ gdb_regs[BFIN_PC] = regs->pc;115115+ gdb_regs[BFIN_CC] = 0;116116+ gdb_regs[BFIN_EXTRA1] = 0;117117+ gdb_regs[BFIN_EXTRA2] = 0;118118+ gdb_regs[BFIN_EXTRA3] = 0;119119+ gdb_regs[BFIN_IPEND] = regs->ipend;120120+}121121+122122+/*123123+ * Extracts ebp, esp and eip values understandable by gdb from the values124124+ * saved by switch_to.125125+ * thread.esp points to ebp. flags and ebp are pushed in switch_to hence esp126126+ * prior to entering switch_to is 8 greater then the value that is saved.127127+ * If switch_to changes, change following code appropriately.128128+ */129129+void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)130130+{131131+ gdb_regs[BFIN_SP] = p->thread.ksp;132132+ gdb_regs[BFIN_PC] = p->thread.pc;133133+ gdb_regs[BFIN_SEQSTAT] = p->thread.seqstat;134134+}135135+136136+void gdb_regs_to_regs(unsigned long *gdb_regs, struct pt_regs *regs)137137+{138138+ regs->r0 = gdb_regs[BFIN_R0];139139+ regs->r1 = gdb_regs[BFIN_R1];140140+ regs->r2 = gdb_regs[BFIN_R2];141141+ regs->r3 = gdb_regs[BFIN_R3];142142+ regs->r4 = gdb_regs[BFIN_R4];143143+ regs->r5 = gdb_regs[BFIN_R5];144144+ regs->r6 = gdb_regs[BFIN_R6];145145+ regs->r7 = gdb_regs[BFIN_R7];146146+ regs->p0 = gdb_regs[BFIN_P0];147147+ regs->p1 = gdb_regs[BFIN_P1];148148+ regs->p2 = gdb_regs[BFIN_P2];149149+ regs->p3 = gdb_regs[BFIN_P3];150150+ regs->p4 = gdb_regs[BFIN_P4];151151+ regs->p5 = gdb_regs[BFIN_P5];152152+ regs->fp = gdb_regs[BFIN_FP];153153+ regs->i0 = gdb_regs[BFIN_I0];154154+ regs->i1 = gdb_regs[BFIN_I1];155155+ regs->i2 = gdb_regs[BFIN_I2];156156+ regs->i3 = gdb_regs[BFIN_I3];157157+ regs->m0 = gdb_regs[BFIN_M0];158158+ regs->m1 = gdb_regs[BFIN_M1];159159+ regs->m2 = gdb_regs[BFIN_M2];160160+ regs->m3 = gdb_regs[BFIN_M3];161161+ regs->b0 = gdb_regs[BFIN_B0];162162+ regs->b1 = gdb_regs[BFIN_B1];163163+ regs->b2 = gdb_regs[BFIN_B2];164164+ regs->b3 = gdb_regs[BFIN_B3];165165+ regs->l0 = gdb_regs[BFIN_L0];166166+ regs->l1 = gdb_regs[BFIN_L1];167167+ regs->l2 = gdb_regs[BFIN_L2];168168+ regs->l3 = gdb_regs[BFIN_L3];169169+ regs->a0x = gdb_regs[BFIN_A0_DOT_X];170170+ regs->a0w = gdb_regs[BFIN_A0_DOT_W];171171+ regs->a1x = gdb_regs[BFIN_A1_DOT_X];172172+ regs->a1w = gdb_regs[BFIN_A1_DOT_W];173173+ regs->rets = gdb_regs[BFIN_RETS];174174+ regs->lc0 = gdb_regs[BFIN_LC0];175175+ regs->lt0 = gdb_regs[BFIN_LT0];176176+ regs->lb0 = gdb_regs[BFIN_LB0];177177+ regs->lc1 = gdb_regs[BFIN_LC1];178178+ regs->lt1 = gdb_regs[BFIN_LT1];179179+ regs->lb1 = gdb_regs[BFIN_LB1];180180+ regs->usp = gdb_regs[BFIN_USP];181181+ regs->syscfg = gdb_regs[BFIN_SYSCFG];182182+ regs->retx = gdb_regs[BFIN_PC];183183+ regs->retn = gdb_regs[BFIN_RETN];184184+ regs->rete = gdb_regs[BFIN_RETE];185185+ regs->pc = gdb_regs[BFIN_PC];186186+187187+#if 0 /* can't change these */188188+ regs->astat = gdb_regs[BFIN_ASTAT];189189+ regs->seqstat = gdb_regs[BFIN_SEQSTAT];190190+ regs->ipend = gdb_regs[BFIN_IPEND];191191+#endif192192+}193193+194194+struct hw_breakpoint {195195+ unsigned int occupied:1;196196+ unsigned int skip:1;197197+ unsigned int enabled:1;198198+ unsigned int type:1;199199+ unsigned int dataacc:2;200200+ unsigned short count;201201+ unsigned int addr;202202+} breakinfo[HW_BREAKPOINT_NUM];203203+204204+int kgdb_arch_init(void)205205+{206206+ kgdb_remove_all_hw_break();207207+ return 0;208208+}209209+210210+int kgdb_set_hw_break(unsigned long addr)211211+{212212+ int breakno;213213+ for (breakno = 0; breakno < HW_BREAKPOINT_NUM; breakno++)214214+ if (!breakinfo[breakno].occupied) {215215+ breakinfo[breakno].occupied = 1;216216+ breakinfo[breakno].enabled = 1;217217+ breakinfo[breakno].type = 1;218218+ breakinfo[breakno].addr = addr;219219+ return 0;220220+ }221221+222222+ return -ENOSPC;223223+}224224+225225+int kgdb_remove_hw_break(unsigned long addr)226226+{227227+ int breakno;228228+ for (breakno = 0; breakno < HW_BREAKPOINT_NUM; breakno++)229229+ if (breakinfo[breakno].addr == addr)230230+ memset(&(breakinfo[breakno]), 0, sizeof(struct hw_breakpoint));231231+232232+ return 0;233233+}234234+235235+void kgdb_remove_all_hw_break(void)236236+{237237+ memset(breakinfo, 0, sizeof(struct hw_breakpoint)*8);238238+}239239+240240+/*241241+void kgdb_show_info(void)242242+{243243+ printk(KERN_DEBUG "hwd: wpia0=0x%x, wpiacnt0=%d, wpiactl=0x%x, wpstat=0x%x\n",244244+ bfin_read_WPIA0(), bfin_read_WPIACNT0(),245245+ bfin_read_WPIACTL(), bfin_read_WPSTAT());246246+}247247+*/248248+249249+void kgdb_correct_hw_break(void)250250+{251251+ int breakno;252252+ int correctit;253253+ uint32_t wpdactl = bfin_read_WPDACTL();254254+255255+ correctit = 0;256256+ for (breakno = 0; breakno < HW_BREAKPOINT_NUM; breakno++) {257257+ if (breakinfo[breakno].type == 1) {258258+ switch (breakno) {259259+ case 0:260260+ if (breakinfo[breakno].enabled && !(wpdactl & WPIAEN0)) {261261+ correctit = 1;262262+ wpdactl &= ~(WPIREN01|EMUSW0);263263+ wpdactl |= WPIAEN0|WPICNTEN0;264264+ bfin_write_WPIA0(breakinfo[breakno].addr);265265+ bfin_write_WPIACNT0(breakinfo[breakno].skip);266266+ } else if (!breakinfo[breakno].enabled && (wpdactl & WPIAEN0)) {267267+ correctit = 1;268268+ wpdactl &= ~WPIAEN0;269269+ }270270+ break;271271+272272+ case 1:273273+ if (breakinfo[breakno].enabled && !(wpdactl & WPIAEN1)) {274274+ correctit = 1;275275+ wpdactl &= ~(WPIREN01|EMUSW1);276276+ wpdactl |= WPIAEN1|WPICNTEN1;277277+ bfin_write_WPIA1(breakinfo[breakno].addr);278278+ bfin_write_WPIACNT1(breakinfo[breakno].skip);279279+ } else if (!breakinfo[breakno].enabled && (wpdactl & WPIAEN1)) {280280+ correctit = 1;281281+ wpdactl &= ~WPIAEN1;282282+ }283283+ break;284284+285285+ case 2:286286+ if (breakinfo[breakno].enabled && !(wpdactl & WPIAEN2)) {287287+ correctit = 1;288288+ wpdactl &= ~(WPIREN23|EMUSW2);289289+ wpdactl |= WPIAEN2|WPICNTEN2;290290+ bfin_write_WPIA2(breakinfo[breakno].addr);291291+ bfin_write_WPIACNT2(breakinfo[breakno].skip);292292+ } else if (!breakinfo[breakno].enabled && (wpdactl & WPIAEN2)) {293293+ correctit = 1;294294+ wpdactl &= ~WPIAEN2;295295+ }296296+ break;297297+298298+ case 3:299299+ if (breakinfo[breakno].enabled && !(wpdactl & WPIAEN3)) {300300+ correctit = 1;301301+ wpdactl &= ~(WPIREN23|EMUSW3);302302+ wpdactl |= WPIAEN3|WPICNTEN3;303303+ bfin_write_WPIA3(breakinfo[breakno].addr);304304+ bfin_write_WPIACNT3(breakinfo[breakno].skip);305305+ } else if (!breakinfo[breakno].enabled && (wpdactl & WPIAEN3)) {306306+ correctit = 1;307307+ wpdactl &= ~WPIAEN3;308308+ }309309+ break;310310+ case 4:311311+ if (breakinfo[breakno].enabled && !(wpdactl & WPIAEN4)) {312312+ correctit = 1;313313+ wpdactl &= ~(WPIREN45|EMUSW4);314314+ wpdactl |= WPIAEN4|WPICNTEN4;315315+ bfin_write_WPIA4(breakinfo[breakno].addr);316316+ bfin_write_WPIACNT4(breakinfo[breakno].skip);317317+ } else if (!breakinfo[breakno].enabled && (wpdactl & WPIAEN4)) {318318+ correctit = 1;319319+ wpdactl &= ~WPIAEN4;320320+ }321321+ break;322322+ case 5:323323+ if (breakinfo[breakno].enabled && !(wpdactl & WPIAEN5)) {324324+ correctit = 1;325325+ wpdactl &= ~(WPIREN45|EMUSW5);326326+ wpdactl |= WPIAEN5|WPICNTEN5;327327+ bfin_write_WPIA5(breakinfo[breakno].addr);328328+ bfin_write_WPIACNT5(breakinfo[breakno].skip);329329+ } else if (!breakinfo[breakno].enabled && (wpdactl & WPIAEN5)) {330330+ correctit = 1;331331+ wpdactl &= ~WPIAEN5;332332+ }333333+ break;334334+ }335335+ }336336+ }337337+ if (correctit) {338338+ wpdactl &= ~WPAND;339339+ wpdactl |= WPPWR;340340+ /*printk("correct_hw_break: wpdactl=0x%x\n", wpdactl);*/341341+ bfin_write_WPDACTL(wpdactl);342342+ CSYNC();343343+ /*kgdb_show_info();*/344344+ }345345+}346346+347347+void kgdb_disable_hw_debug(struct pt_regs *regs)348348+{349349+ /* Disable hardware debugging while we are in kgdb */350350+ bfin_write_WPIACTL(bfin_read_WPIACTL() & ~0x1);351351+ CSYNC();352352+}353353+354354+void kgdb_post_master_code(struct pt_regs *regs, int eVector, int err_code)355355+{356356+ /* Master processor is completely in the debugger */357357+ gdb_bf533vector = eVector;358358+ gdb_bf533errcode = err_code;359359+}360360+361361+int kgdb_arch_handle_exception(int exceptionVector, int signo,362362+ int err_code, char *remcom_in_buffer,363363+ char *remcom_out_buffer,364364+ struct pt_regs *linux_regs)365365+{366366+ long addr;367367+ long breakno;368368+ char *ptr;369369+ int newPC;370370+ int wp_status;371371+372372+ switch (remcom_in_buffer[0]) {373373+ case 'c':374374+ case 's':375375+ if (kgdb_contthread && kgdb_contthread != current) {376376+ strcpy(remcom_out_buffer, "E00");377377+ break;378378+ }379379+380380+ kgdb_contthread = NULL;381381+382382+ /* try to read optional parameter, pc unchanged if no parm */383383+ ptr = &remcom_in_buffer[1];384384+ if (kgdb_hex2long(&ptr, &addr)) {385385+ linux_regs->retx = addr;386386+ }387387+ newPC = linux_regs->retx;388388+389389+ /* clear the trace bit */390390+ linux_regs->syscfg &= 0xfffffffe;391391+392392+ /* set the trace bit if we're stepping */393393+ if (remcom_in_buffer[0] == 's') {394394+ linux_regs->syscfg |= 0x1;395395+ debugger_step = 1;396396+ }397397+398398+ wp_status = bfin_read_WPSTAT();399399+ CSYNC();400400+401401+ if (exceptionVector == VEC_WATCH) {402402+ for (breakno = 0; breakno < 6; ++breakno) {403403+ if (wp_status & (1 << breakno)) {404404+ breakinfo->skip = 1;405405+ break;406406+ }407407+ }408408+ }409409+ kgdb_correct_hw_break();410410+411411+ bfin_write_WPSTAT(0);412412+413413+ return 0;414414+ } /* switch */415415+ return -1; /* this means that we do not want to exit from the handler */416416+}417417+418418+struct kgdb_arch arch_kgdb_ops = {419419+ .gdb_bpt_instr = {0xa1},420420+ .flags = KGDB_HW_BREAKPOINT,421421+};
+1-1
drivers/serial/Kconfig
···556556557557config SERIAL_BFIN_DMA558558 bool "DMA mode"559559- depends on DMA_UNCACHED_1M559559+ depends on DMA_UNCACHED_1M && !KGDB_UART560560 help561561 This driver works under DMA mode. If this option is selected, the562562 blackfin simple dma driver is also enabled.
···11+/*22+ * File: include/asm-blackfin/kgdb.h33+ * Based on:44+ * Author: Sonic Zhang55+ *66+ * Created:77+ * Description:88+ *99+ * Rev: $Id: kgdb_bfin_linux-2.6.x.patch 4934 2007-02-13 09:32:11Z sonicz $1010+ *1111+ * Modified:1212+ * Copyright 2005-2006 Analog Devices Inc.1313+ *1414+ * Bugs: Enter bugs at http://blackfin.uclinux.org/1515+ *1616+ * This program is free software; you can redistribute it and/or modify1717+ * it under the terms of the GNU General Public License as published by1818+ * the Free Software Foundation; either version 2 of the License, or1919+ * (at your option) any later version.2020+ *2121+ * This program is distributed in the hope that it will be useful,2222+ * but WITHOUT ANY WARRANTY; without even the implied warranty of2323+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2424+ * GNU General Public License for more details.2525+ *2626+ * You should have received a copy of the GNU General Public License2727+ * along with this program; if not, see the file COPYING, or write2828+ * to the Free Software Foundation, Inc.,2929+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA3030+ */3131+3232+#ifndef __ASM_BLACKFIN_KGDB_H__3333+#define __ASM_BLACKFIN_KGDB_H__3434+3535+#include <linux/ptrace.h>3636+3737+/* gdb locks */3838+#define KGDB_MAX_NO_CPUS 83939+4040+/************************************************************************/4141+/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/4242+/* at least NUMREGBYTES*2 are needed for register packets */4343+/* Longer buffer is needed to list all threads */4444+#define BUFMAX 20484545+4646+/*4747+ * Note that this register image is different from4848+ * the register image that Linux produces at interrupt time.4949+ * 5050+ * Linux's register image is defined by struct pt_regs in ptrace.h.5151+ */5252+enum regnames {5353+ /* Core Registers */5454+ BFIN_R0 = 0,5555+ BFIN_R1,5656+ BFIN_R2,5757+ BFIN_R3,5858+ BFIN_R4,5959+ BFIN_R5,6060+ BFIN_R6,6161+ BFIN_R7,6262+ BFIN_P0,6363+ BFIN_P1,6464+ BFIN_P2,6565+ BFIN_P3,6666+ BFIN_P4,6767+ BFIN_P5,6868+ BFIN_SP,6969+ BFIN_FP,7070+ BFIN_I0,7171+ BFIN_I1,7272+ BFIN_I2,7373+ BFIN_I3,7474+ BFIN_M0,7575+ BFIN_M1,7676+ BFIN_M2,7777+ BFIN_M3,7878+ BFIN_B0,7979+ BFIN_B1,8080+ BFIN_B2,8181+ BFIN_B3,8282+ BFIN_L0,8383+ BFIN_L1,8484+ BFIN_L2,8585+ BFIN_L3,8686+ BFIN_A0_DOT_X,8787+ BFIN_A0_DOT_W,8888+ BFIN_A1_DOT_X,8989+ BFIN_A1_DOT_W,9090+ BFIN_ASTAT,9191+ BFIN_RETS,9292+ BFIN_LC0,9393+ BFIN_LT0,9494+ BFIN_LB0,9595+ BFIN_LC1,9696+ BFIN_LT1,9797+ BFIN_LB1,9898+ BFIN_CYCLES,9999+ BFIN_CYCLES2,100100+ BFIN_USP,101101+ BFIN_SEQSTAT,102102+ BFIN_SYSCFG,103103+ BFIN_RETI,104104+ BFIN_RETX,105105+ BFIN_RETN,106106+ BFIN_RETE,107107+108108+ /* Pseudo Registers */109109+ BFIN_PC,110110+ BFIN_CC,111111+ BFIN_EXTRA1, /* Address of .text section. */112112+ BFIN_EXTRA2, /* Address of .data section. */113113+ BFIN_EXTRA3, /* Address of .bss section. */114114+ BFIN_FDPIC_EXEC, 115115+ BFIN_FDPIC_INTERP,116116+117117+ /* MMRs */118118+ BFIN_IPEND,119119+120120+ /* LAST ENTRY SHOULD NOT BE CHANGED. */121121+ BFIN_NUM_REGS /* The number of all registers. */122122+};123123+124124+/* Number of bytes of registers. */125125+#define NUMREGBYTES BFIN_NUM_REGS*4126126+127127+#define BREAKPOINT() asm(" EXCPT 2;");128128+#define BREAK_INSTR_SIZE 2129129+#define HW_BREAKPOINT_NUM 6130130+131131+/* Instruction watchpoint address control register bits mask */132132+#define WPPWR 0x1133133+#define WPIREN01 0x2134134+#define WPIRINV01 0x4135135+#define WPIAEN0 0x8136136+#define WPIAEN1 0x10137137+#define WPICNTEN0 0x20138138+#define WPICNTEN1 0x40139139+#define EMUSW0 0x80140140+#define EMUSW1 0x100141141+#define WPIREN23 0x200142142+#define WPIRINV23 0x400143143+#define WPIAEN2 0x800144144+#define WPIAEN3 0x1000145145+#define WPICNTEN2 0x2000146146+#define WPICNTEN3 0x4000147147+#define EMUSW2 0x8000148148+#define EMUSW3 0x10000149149+#define WPIREN45 0x20000150150+#define WPIRINV45 0x40000151151+#define WPIAEN4 0x80000152152+#define WPIAEN5 0x100000153153+#define WPICNTEN4 0x200000154154+#define WPICNTEN5 0x400000155155+#define EMUSW4 0x800000156156+#define EMUSW5 0x1000000157157+#define WPAND 0x2000000158158+159159+/* Data watchpoint address control register bits mask */160160+#define WPDREN01 0x1161161+#define WPDRINV01 0x2162162+#define WPDAEN0 0x4163163+#define WPDAEN1 0x8164164+#define WPDCNTEN0 0x10165165+#define WPDCNTEN1 0x20166166+#define WPDSRC0 0xc0167167+#define WPDACC0 0x300168168+#define WPDSRC1 0xc00169169+#define WPDACC1 0x3000170170+171171+/* Watchpoint status register bits mask */172172+#define STATIA0 0x1173173+#define STATIA1 0x2174174+#define STATIA2 0x4175175+#define STATIA3 0x8176176+#define STATIA4 0x10177177+#define STATIA5 0x20178178+#define STATDA0 0x40179179+#define STATDA1 0x80180180+181181+extern void kgdb_print(const char *fmt, ...);182182+183183+#endif