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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [common/] [current/] [src/] [dbg-threads-syscall.c] - Blame information for rev 856

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

Line No. Rev Author Line
1 786 skrzyp
//========================================================================
2
//
3
//      dbg-threads-syscall.c
4
//
5
//      Pseudo system calls for multi-threaded debug support
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):     Red Hat, nickg
43
// Contributors:  Red Hat, nickg
44
// Date:          1998-08-25
45
// Purpose:       
46
// Description:   Pseudo system calls to bind system specific multithread
47
//                debug support with a ROM monitor, cygmon. We call it
48
//                Cygmon, but the feature lives in libstub.
49
// Usage:         
50
//
51
//####DESCRIPTIONEND####
52
//
53
//========================================================================
54
 
55
#include <pkgconf/system.h>
56
#include <pkgconf/hal.h>
57
 
58
#if !defined(CYGPKG_KERNEL) && defined(CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT)
59
 
60
/* Only include this code if we do not have a kernel. Otherwise the kernel
61
 * supplies these functions for the app we are linked with.
62
 */
63
 
64
#include <cyg/hal/dbg-threads-api.h>
65
#include <cyg/hal/dbg-thread-syscall.h>
66
 
67
 
68
static dbg_syscall_func * dbg_syscall_ptr ;
69
 
70
static union dbg_thread_syscall_parms tcall ;
71
 
72
/* ----- INIT_THREADS_SYSCALL --------------------------------------- */
73
/* Some external bing and configuration logic knows how to setup
74
   the ststem calls. In the first implementation, we have used a vector
75
   in the secondary vector table. This functions allows us to isolate that
76
   sort of system specific detail. Similarly, we do not export the
77
   specific detail of a dbg_syscall_func.
78
 */
79
 
80
 
81
void init_threads_syscall(void * vector)
82
{
83
   dbg_syscall_ptr = vector ; /* AH, the easy compatability of the
84
   void pointer*/
85
} /* init_threads_syscall */
86
 
87
/* All forms of failure return 0 */
88
/* Whether non support, incomplete initialization, unknown thread */
89
static __inline__ int dbg_thread_syscall(
90
                                     enum dbg_syscall_ids id)
91
{
92
  dbg_syscall_func f ; /* double indirect via */
93
  if (0 == dbg_syscall_ptr) return 0; /* dbg_syscall_ptr never init'd */
94
  if (0 ==(f = *dbg_syscall_ptr)) return 0 ;  /* vector not initialized */
95
  return (*f)(id,&tcall);
96
}
97
 
98
 
99
 
100
 
101
/* ------- INIT_THREAD_SYSCALL -------------------------------------------  */
102
/* Received the address of the entry in the secondary interrupt vector table */
103
/* This table is the interchange between the O.S. and Cygmon/libstub         */
104
/* This could get more complex so, I am doing it with a function
105
   rather than exposing the internals.
106
 */
107
void init_thread_syscall(void * vector)
108
{
109
  dbg_syscall_ptr = vector ;
110
}
111
 
112
int dbg_thread_capabilities(struct dbg_capabilities * cbp)
113
{
114
#if 0    
115
  tcall.cap_parms.abilities = cbp ;
116
  return dbg_thread_syscall(dbg_capabilities_func) ;
117
#else
118
    cbp->mask1 = has_thread_current     |
119
        has_thread_registers            |
120
        has_thread_reg_change           |
121
        has_thread_list                 |
122
        has_thread_info                 ;
123
    return 1 ;
124
#endif  
125
}
126
 
127
int dbg_currthread(threadref * varparm)
128
{
129
  tcall.currthread_parms.ref = varparm ;
130
  return dbg_thread_syscall(dbg_currthread_func) ;
131
}
132
 
133
 
134
int dbg_threadlist(
135
                   int startflag,
136
                   threadref * lastthreadid,
137
                   threadref * next_thread
138
                   )
139
{
140
  tcall.threadlist_parms.startflag = startflag ;
141
  tcall.threadlist_parms.lastid = lastthreadid ;
142
  tcall.threadlist_parms.nextthreadid = next_thread ;
143
  return dbg_thread_syscall(dbg_threadlist_func) ;
144
}
145
 
146
int dbg_threadinfo(
147
                   threadref * threadid,
148
                   struct cygmon_thread_debug_info * info)
149
{
150
  tcall.info_parms.ref = threadid ;
151
  tcall.info_parms.info = info ;
152
  return dbg_thread_syscall(dbg_threadinfo_func) ;
153
}
154
 
155
int dbg_getthreadreg(
156
                     threadref * osthreadid,
157
                     int regcount, /* count of registers in the array */
158
                     void * regval)  /* fillin this array */
159
{
160
  tcall.reg_parms.thread =    osthreadid ;
161
  tcall.reg_parms.regcount =  regcount ;
162
  tcall.reg_parms.registers = regval ;
163
  return dbg_thread_syscall(dbg_getthreadreg_func) ;
164
}
165
 
166
int dbg_setthreadreg(
167
                     threadref * osthreadid,
168
                     int regcount , /* number of registers */
169
                     void * regval)
170
{
171
  tcall.reg_parms.thread =    osthreadid ;
172
  tcall.reg_parms.regcount =  regcount ;
173
  tcall.reg_parms.registers =  regval ;
174
  return dbg_thread_syscall(dbg_setthreadreg_func) ;
175
} /* dbg_setthreadreg */
176
 
177
int dbg_scheduler(threadref *thread_id, int lock, int mode)
178
{
179
  tcall.scheduler_parms.thread    = thread_id;
180
  tcall.scheduler_parms.lock      = lock ;
181
  tcall.scheduler_parms.mode      = mode ;
182
 
183
  return dbg_thread_syscall(dbg_scheduler_func) ;
184
}
185
 
186
 
187
 
188
#if (CYG_BYTEORDER == CYG_LSBFIRST)
189
 
190
unsigned long swap32(unsigned long x)
191
{
192
    unsigned long r = 0;
193
 
194
    r |= (x>>24)&0xFF;
195
    r |= ((x>>16)&0xFF)<<8;
196
    r |= ((x>>8)&0xFF)<<16;
197
    r |= ((x)&0xFF)<<24;
198
 
199
    return r;
200
}
201
 
202
#else
203
 
204
#define swap32(x) ((unsigned long)(x))
205
 
206
#endif
207
 
208
int dbg_currthread_id(void)
209
{
210
    threadref ref;
211
    if( dbg_currthread( &ref ) )
212
        return (cyg_uint16)swap32(((unsigned long *)ref)[1]);
213
    else return 0;
214
}
215
 
216
#endif

powered by: WebSVN 2.1.0

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