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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mips/] [jmr3904/] [v2_0/] [src/] [plf_misc.c] - Blame information for rev 587

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

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      plf_misc.c
4
//
5
//      HAL platform miscellaneous functions
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):    nickg
44
// Contributors: nickg, jlarmour
45
// Date:         1999-01-21
46
// Purpose:      HAL miscellaneous functions
47
// Description:  This file contains miscellaneous functions provided by the
48
//               HAL.
49
//
50
//####DESCRIPTIONEND####
51
//
52
//========================================================================*/
53
 
54
#include <pkgconf/hal.h>
55
 
56
#include <cyg/infra/cyg_type.h>         // Base types
57
#include <cyg/infra/cyg_trac.h>         // tracing macros
58
#include <cyg/infra/cyg_ass.h>          // assertion macros
59
 
60
#include <cyg/hal/hal_arch.h>           // architectural definitions
61
 
62
#include <cyg/hal/hal_intr.h>           // Interrupt handling
63
 
64
#include <cyg/hal/hal_cache.h>          // Cache handling
65
 
66
/*------------------------------------------------------------------------*/
67
 
68
extern void patch_dbg_syscalls(void * vector);
69
 
70
/*------------------------------------------------------------------------*/
71
 
72
void hal_platform_init(void)
73
{
74
 
75
    HAL_ICACHE_INVALIDATE_ALL();
76
    HAL_ICACHE_ENABLE();
77
    HAL_DCACHE_INVALIDATE_ALL();
78
    HAL_DCACHE_ENABLE();
79
 
80
#if !defined(CYGHWR_HAL_MIPS_TX39_JMR3904_ENABLE_TOE)
81
 
82
    HAL_TX39_DEBUG_TOE_DISABLE();
83
 
84
#else
85
 
86
    HAL_TX39_DEBUG_TOE_ENABLE();
87
 
88
#endif
89
 
90
#if defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT)   && \
91
    defined(CYGSEM_HAL_USE_ROM_MONITOR_CygMon)
92
    {
93
        patch_dbg_syscalls( (void *)(&hal_vsr_table[0]) );
94
    }
95
#endif
96
 
97
}
98
 
99
/*------------------------------------------------------------------------*/
100
/* Functions to support the detection and execution of a user provoked    */
101
/* program break. These are usually called from interrupt routines.       */
102
 
103
cyg_bool cyg_hal_is_break(char *buf, int size)
104
{
105
    while( size )
106
        if( buf[--size] == 0x03 ) return true;
107
 
108
    return false;
109
}
110
 
111
void cyg_hal_user_break( CYG_ADDRWORD *regs )
112
{
113
#if defined(CYGSEM_HAL_USE_ROM_MONITOR_CygMon)
114
    // The following code should be at the very start of this function so
115
    // that it can access the RA register before it is saved and reused.
116
    register CYG_WORD32 ra;
117
    asm volatile ( "move %0,$31;" : "=r" (ra) );
118
 
119
        {
120
            typedef void install_bpt_fn(void *epc);
121
            CYG_WORD32 pc;
122
            HAL_SavedRegisters *sreg = (HAL_SavedRegisters *)regs;
123
            install_bpt_fn *ibp = (install_bpt_fn *)hal_vsr_table[35];
124
 
125
            if( regs == NULL ) pc = ra;
126
            else pc = sreg->pc;
127
 
128
            if( ibp != NULL ) ibp((void *)pc);
129
        }
130
 
131
#elif defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
132
 
133
        {
134
            extern void breakpoint(void);
135
            breakpoint();
136
        }
137
 
138
#else
139
 
140
        HAL_BREAKPOINT(breakinst);
141
 
142
#endif
143
 
144
}
145
 
146
/*------------------------------------------------------------------------*/
147
/* Control C ISR support                                                  */
148
 
149
#if defined(CYGDBG_HAL_MIPS_DEBUG_GDB_CTRLC_SUPPORT)
150
 
151
#define DIAG_BASE       0xfffff300
152
#define DIAG_SLCR       (DIAG_BASE+0x00)
153
#define DIAG_SLSR       (DIAG_BASE+0x04)
154
#define DIAG_SLDICR     (DIAG_BASE+0x08)
155
#define DIAG_SLDISR     (DIAG_BASE+0x0C)
156
#define DIAG_SFCR       (DIAG_BASE+0x10)
157
#define DIAG_SBRG       (DIAG_BASE+0x14)
158
#define DIAG_TFIFO      (DIAG_BASE+0x20)
159
#define DIAG_RFIFO      (DIAG_BASE+0x30)
160
 
161
#define BRG_T0          0x0000
162
#define BRG_T2          0x0100
163
#define BRG_T4          0x0200
164
#define BRG_T5          0x0300
165
 
166
struct Hal_SavedRegisters *hal_saved_interrupt_state;
167
 
168
void hal_ctrlc_isr_init(void)
169
{
170
    CYG_WORD16 dicr;
171
 
172
    HAL_READ_UINT16( DIAG_SLDICR , dicr );
173
    dicr = 0x0001;
174
    HAL_WRITE_UINT16( DIAG_SLDICR , dicr );
175
 
176
    HAL_INTERRUPT_SET_LEVEL( CYGHWR_HAL_GDB_PORT_VECTOR, 1 );
177
    HAL_INTERRUPT_UNMASK( CYGHWR_HAL_GDB_PORT_VECTOR );
178
}
179
 
180
cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
181
{
182
    char c;
183
    CYG_WORD16 disr;
184
 
185
    HAL_INTERRUPT_ACKNOWLEDGE( CYGHWR_HAL_GDB_PORT_VECTOR );
186
 
187
    HAL_READ_UINT16( DIAG_SLDISR , disr );
188
 
189
    if( disr & 0x0001 )
190
    {
191
 
192
        disr = disr & ~0x0001;
193
 
194
        HAL_READ_UINT8( DIAG_RFIFO, c );
195
 
196
        HAL_WRITE_UINT16( DIAG_SLDISR , disr );
197
 
198
        if( cyg_hal_is_break( &c , 1 ) )
199
            cyg_hal_user_break( (CYG_ADDRWORD *)hal_saved_interrupt_state );
200
    }
201
 
202
    return 2;
203
}
204
 
205
#endif
206
 
207
/*------------------------------------------------------------------------*/
208
/* End of plf_misc.c                                                      */

powered by: WebSVN 2.1.0

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