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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [cygmon/] [v2_0/] [misc/] [breakpoints.c] - Blame information for rev 361

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      breakpoints.c
4
//
5
//      Support aribtrary set of breakpoints.
6
//
7
//==========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//==========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):    
44
// Contributors: gthomas
45
// Date:         1999-10-20
46
// Purpose:      
47
// Description:  
48
//               
49
//
50
//####DESCRIPTIONEND####
51
//
52
//=========================================================================
53
 
54
#include "board.h"
55
 
56
#ifndef USE_ECOS_HAL_BREAKPOINTS
57
 
58
#include <stdlib.h>
59
#ifdef HAVE_BSP
60
#include <bsp/bsp.h>
61
#include <bsp/cpu.h>
62
#endif
63
 
64
#include "monitor.h"
65
#include "tservice.h"
66
#include "stub-tservice.h"
67
 
68
#include "fmt_util.h"
69
 
70
 
71
static struct bp *last_bp_ptr;
72
static struct bp *first_bp_ptr;
73
 
74
#ifdef NO_MALLOC
75
static struct bp *free_bp_list;
76
static struct bp bp_list[MAX_NUM_BP];
77
static int       curr_bp_num;
78
#endif
79
 
80
int
81
add_mon_breakpoint (mem_addr_t location)
82
{
83
  struct bp *ptr;
84
  struct bp *new_bp_ptr;
85
 
86
  for (ptr = first_bp_ptr; ptr != NULL; ptr = ptr->next)
87
    {
88
      if (MEM_ADDR_EQ_P (ptr->address, location))
89
        return 1;
90
    }
91
#ifdef NO_MALLOC
92
  if (free_bp_list != NULL)
93
    {
94
      new_bp_ptr = free_bp_list;
95
      free_bp_list = new_bp_ptr->next;
96
    }
97
  else
98
    {
99
      if (curr_bp_num < MAX_NUM_BP)
100
        {
101
          new_bp_ptr = &bp_list[curr_bp_num++];
102
        }
103
      else
104
        {
105
          xprintf ("No more breakpoints\n");
106
          return 1;
107
        }
108
    }
109
#else
110
  new_bp_ptr = (struct bp *)malloc (sizeof (struct bp));
111
#endif
112
 
113
  if (first_bp_ptr == NULL)
114
    {
115
      first_bp_ptr = new_bp_ptr;
116
    }
117
  else
118
    {
119
      last_bp_ptr->next = new_bp_ptr;
120
    }
121
  last_bp_ptr = new_bp_ptr;
122
 
123
  last_bp_ptr->next = NULL;
124
  last_bp_ptr->address = location;
125
  last_bp_ptr->in_memory = 0;
126
  return 0;
127
}
128
 
129
 
130
void
131
install_breakpoints (void)
132
{
133
  struct bp *ptr = first_bp_ptr;
134
  while (ptr != NULL)
135
    {
136
      set_breakpoint (ptr);
137
      ptr = ptr->next;
138
    }
139
}
140
 
141
 
142
void
143
clear_breakpoints (void)
144
{
145
  struct bp *ptr = first_bp_ptr;
146
 
147
  while (ptr != NULL)
148
    {
149
      clear_breakpoint (ptr);
150
      ptr = ptr->next;
151
    }
152
}
153
 
154
int
155
show_breakpoints (void)
156
{
157
  struct bp *ptr;
158
 
159
  for (ptr = first_bp_ptr; ptr != NULL; ptr = ptr->next)
160
    {
161
      char buf[20];
162
 
163
      addr2str (&ptr->address, buf);
164
      xprintf ("%s\n", buf);
165
    }
166
 
167
  return 0;
168
}
169
 
170
 
171
 
172
int
173
clear_mon_breakpoint (mem_addr_t location)
174
{
175
  int error = 0;
176
  struct bp *ptr = first_bp_ptr;
177
  struct bp *prev_ptr = NULL;
178
 
179
  /* Scan the list looking for the address to clear */
180
  while (ptr != NULL && !MEM_ADDR_EQ_P (ptr->address, location))
181
    {
182
      /* keep a pointer one behind the current position */
183
      prev_ptr = ptr;
184
      ptr = ptr->next;
185
    }
186
  if (ptr == NULL)
187
    {
188
      xprintf ("That address has no breakpoint on it.\n");
189
      error = 1;
190
    }
191
  else
192
    {
193
      /* Just in case it's still in memory. */
194
      clear_breakpoint (ptr);
195
 
196
      /* now we'll point the previous bp->next at the one after the one
197
         we're deleting, unless there is no previous bp. */
198
      if (prev_ptr != NULL)
199
        {
200
          prev_ptr->next = ptr->next;
201
        }
202
 
203
      if (first_bp_ptr == ptr)
204
        first_bp_ptr = ptr->next;
205
 
206
      if (last_bp_ptr == ptr)
207
        last_bp_ptr = prev_ptr;
208
 
209
      /* eliminate the offending bp struct */
210
#ifdef NO_MALLOC
211
      ptr->next = free_bp_list;
212
      free_bp_list = ptr;
213
#else
214
      free (ptr);
215
#endif
216
    }
217
  return error;
218
}
219
 
220
#endif /* USE_ECOS_HAL_BREAKPOINTS */

powered by: WebSVN 2.1.0

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