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

4.104.114.84.95
Last change on this file since cba119c9 was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/21/04 at 16:01:48

Remove duplicate white lines.

  • 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.rtems.com/license/LICENSE.
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#include <stdio.h>
22#include <string.h>
23
24/*
25
26We're going to call right down into the uart driver because we're
27operating within an exception.  if things are broken because something
28bad happened, this may be our last chance to debug before RTEMS goes
29mad, so we won't rely on the I/O subsystem to be operating.  This is a
30little messy, but at least we're not talking right to the hardware.
31
32*/
33
34extern int mg5uart_set_attributes(int minor,const struct termios *t);
35extern int mg5uart_open(int major,int minor, void *arg);
36extern int mg5uart_close(int major,int minor, void *arg);
37extern void mg5uart_write_polled(int minor, char c );
38extern int mg5uart_inbyte_nonblocking_polled(int minor);
39
40static int debugUartEnabled = 0;
41
42int mg5rdbgOpenGDBuart(int breakoninit)
43{
44   struct termios t;
45   memset(&t,0,sizeof(struct termios));
46
47   if( mg5uart_open(0,1,NULL) != RTEMS_SUCCESSFUL )
48   {
49      printf("gdbstub: Failed to open UART port 2\n");
50      return -1;
51   }
52
53   t.c_cflag |= B19200;
54   t.c_cflag |= CS8;
55   if( mg5uart_set_attributes(1,&t) != 0 )
56   {
57      printf("gdbstub: Failed to configure UART 2 for 19200N82\n");
58      return -1;
59   }
60   printf("gdbstub: UART 2 configured for 19200N82\n");
61
62   debugUartEnabled  = -1;
63
64   /* set up vectoring for gdb */
65   mips_gdb_stub_install(-1);
66
67   /*
68      this is a rough approximation of our memory map.  Yours is
69      probably different.  It only needs to be sufficient for the stub
70      to know what it can and can't do and where.
71   */
72   gdbstub_add_memsegment(0         , 0x8001ffff, MEMOPT_READABLE );
73   gdbstub_add_memsegment(0x80020000, 0x80afffff, MEMOPT_READABLE | MEMOPT_WRITEABLE );
74   gdbstub_add_memsegment(0x80b00000, 0x814fffff, MEMOPT_READABLE );
75   gdbstub_add_memsegment(0x81500000, 0x81ffffff, MEMOPT_READABLE | MEMOPT_WRITEABLE );
76
77   if( breakoninit )
78   {
79      printf("gdbstub: GDB stub entered, connect host debugger now\n");
80      /*
81         break to gdb.  We'll wait there for the operator to get their gdb
82         going, then they can 'continue' or do whatever.
83      */
84      mips_break(0);
85      printf("gdbstub: User code running\n");
86   }
87   else
88      printf("gdbstub: GDB stub ready for exceptions\n");
89
90   return RTEMS_SUCCESSFUL;
91}
92
93void mg5rdbgCloseGDBuart(void)
94{
95   mg5uart_close(0,1,NULL);
96   debugUartEnabled  = 0;
97}
98
99char getDebugChar (void)
100{
101   if( debugUartEnabled )
102   {
103      int rv;
104
105      while( (rv = mg5uart_inbyte_nonblocking_polled(1)) < 0 );
106      return (char)rv;
107   }
108
109   return 0;
110}
111
112void putDebugChar (char c)
113{
114   if( debugUartEnabled )
115      return mg5uart_write_polled(1,c);
116}
117
118/*
119   {
120      * initialize hardware pc and data breakpoints to quiet state*
121      uint32_t   dcic, reg, mask;
122
123      reg = 0xffffffff;
124      mask = 0xffffffff;
125
126      mips_set_bpcrm( reg, mask );
127      mips_set_bdarm( reg, mask );
128
129      mips_get_dcic( dcic );
130      * configure dcic for trapping, user & kernel mode, PC traps and enable it *
131      dcic = DCIC_TR | DCIC_UD | DCIC_KD | DCIC_PCE | DCIC_DE;
132      * dcic = DCIC_UD | DCIC_KD | DCIC_PCE | DCIC_DE; *
133      mips_set_dcic( dcic );
134
135      mips_get_bpcrm( reg, mask );
136      mips_get_dcic( dcic );
137      * printf("bpc is %08X, bpc_mask is %08X, dcic is now %08X\n", reg, mask, dcic ); *
138   }
139*/
Note: See TracBrowser for help on using the repository browser.