OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [mips/] [genmongoosev/] [startup/] [gdb-support.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  gdb-support.c,v 1.3 2002/03/08 16:26:03 joel Exp
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
 
25
We're going to call right down into the uart driver because we're
26
operating within an exception.  if things are broken because something
27
bad happened, this may be our last chance to debug before RTEMS goes
28
mad, so we won't rely on the I/O subsystem to be operating.  This is a
29
little messy, but at least we're not talking right to the hardware.
30
 
31
*/
32
 
33
extern int mg5uart_set_attributes(int minor,const struct termios *t);
34
extern int mg5uart_open(int major,int minor, void *arg);
35
extern int mg5uart_close(int major,int minor, void *arg);
36
extern void mg5uart_write_polled(int minor, char c );
37
extern int mg5uart_inbyte_nonblocking_polled(int minor);
38
 
39
 
40
static int debugUartEnabled = 0;
41
 
42
 
43
 
44
 
45
 
46
int 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
 
99
void mg5rdbgCloseGDBuart(void)
100
{
101
   mg5uart_close(0,1,NULL);
102
   debugUartEnabled  = 0;
103
}
104
 
105
 
106
 
107
 
108
char 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
 
122
void 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
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.