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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [common/] [v2_0/] [src/] [dbg-threads-syscall.c] - Blame information for rev 324

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

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

powered by: WebSVN 2.1.0

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