source: rtems/c/src/lib/libbsp/mips/genmongoosev/startup/gdb-support.c @ ffdc659

4.104.114.84.95
Last change on this file since ffdc659 was ffdc659, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 8, 2002 at 4:26:03 PM

2002-03-05 Greg Menke <gregory.menke@…>

  • startup/gdb-support.c: Added calls into the mips-support gdb stub for configuring the memory regions. Any bsp that wants to use the gdbstub will need to do something similar.
  • startup/Makefile.am: Added shared/gdbstub directory to include path.
  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 *  GDB Support Routines for the Mongoose-V
3 *
4 *  COPYRIGHT (c) 1989-2002.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14#include <rtems.h>
15#include <rtems/bspIo.h>
16#include <libcpu/mongoose-v.h>
17#include "gdb_if.h"
18
19#include <rtems/libio.h>
20
21
22
23/*
24
25We're going to call right down into the uart driver because we're
26operating within an exception.  if things are broken because something
27bad happened, this may be our last chance to debug before RTEMS goes
28mad, so we won't rely on the I/O subsystem to be operating.  This is a
29little messy, but at least we're not talking right to the hardware.
30
31*/
32
33extern int mg5uart_set_attributes(int minor,const struct termios *t);
34extern int mg5uart_open(int major,int minor, void *arg);
35extern int mg5uart_close(int major,int minor, void *arg);
36extern void mg5uart_write_polled(int minor, char c );
37extern int mg5uart_inbyte_nonblocking_polled(int minor);
38
39
40static int debugUartEnabled = 0;
41
42
43
44
45
46int mg5rdbgOpenGDBuart(int breakoninit)
47{
48   struct termios t;
49   memset(&t,0,sizeof(struct termios));
50
51   if( mg5uart_open(0,1,NULL) != RTEMS_SUCCESSFUL )
52   {
53      printf("gdbstub: Failed to open UART port 2\n");
54      return -1;
55   }
56
57   t.c_cflag |= B19200;
58   t.c_cflag |= CS8;
59   if( mg5uart_set_attributes(1,&t) != 0 )
60   {
61      printf("gdbstub: Failed to configure UART 2 for 19200N82\n");
62      return -1;
63   }
64   printf("gdbstub: UART 2 configured for 19200N82\n");
65
66   debugUartEnabled  = -1;
67
68   /* set up vectoring for gdb */
69   mips_gdb_stub_install(-1);
70
71   /*
72      this is a rough approximation of our memory map.  Yours is
73      probably different.  It only needs to be sufficient for the stub
74      to know what it can and can't do and where.
75   */
76   gdbstub_add_memsegment(0         , 0x8001ffff, MEMOPT_READABLE );
77   gdbstub_add_memsegment(0x80020000, 0x80afffff, MEMOPT_READABLE | MEMOPT_WRITEABLE );
78   gdbstub_add_memsegment(0x80b00000, 0x814fffff, MEMOPT_READABLE );
79   gdbstub_add_memsegment(0x81500000, 0x81ffffff, MEMOPT_READABLE | MEMOPT_WRITEABLE );
80
81
82   if( breakoninit ) 
83   {
84      printf("gdbstub: GDB stub entered, connect host debugger now\n");
85      /*
86         break to gdb.  We'll wait there for the operator to get their gdb
87         going, then they can 'continue' or do whatever.
88      */
89      mips_break(0);
90      printf("gdbstub: User code running\n");
91   }
92   else
93      printf("gdbstub: GDB stub ready for exceptions\n");
94
95   return RTEMS_SUCCESSFUL;
96}
97
98
99void mg5rdbgCloseGDBuart(void)
100{
101   mg5uart_close(0,1,NULL);
102   debugUartEnabled  = 0;
103}
104
105
106
107
108char getDebugChar (void)
109{
110   if( debugUartEnabled )
111   {
112      int rv;
113
114      while( (rv = mg5uart_inbyte_nonblocking_polled(1)) < 0 );
115      return (char)rv;
116   }
117
118   return 0;
119}
120
121
122void putDebugChar (char c)
123{
124   if( debugUartEnabled )
125      return mg5uart_write_polled(1,c);
126}
127
128
129
130
131/*
132   {
133      * initialize hardware pc and data breakpoints to quiet state*
134      unsigned32 dcic, reg, mask;
135
136      reg = 0xffffffff;
137      mask = 0xffffffff;
138
139      mips_set_bpcrm( reg, mask );
140      mips_set_bdarm( reg, mask );
141
142      mips_get_dcic( dcic );
143      * configure dcic for trapping, user & kernel mode, PC traps and enable it *
144      dcic = DCIC_TR | DCIC_UD | DCIC_KD | DCIC_PCE | DCIC_DE;
145      * dcic = DCIC_UD | DCIC_KD | DCIC_PCE | DCIC_DE; *
146      mips_set_dcic( dcic );
147
148      mips_get_bpcrm( reg, mask );
149      mips_get_dcic( dcic );
150      * printf("bpc is %08X, bpc_mask is %08X, dcic is now %08X\n", reg, mask, dcic ); *
151   }
152*/
153
Note: See TracBrowser for help on using the repository browser.