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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [cygmon/] [current/] [misc/] [breakpoints.c] - Blame information for rev 839

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

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