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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mn10300/] [asb2305/] [v2_0/] [src/] [plf_misc.c] - Blame information for rev 773

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):    dmoseley (based on the original by nickg)
44
// Contributors: nickg, jlarmour, dmoseley
45
// Date:         2000-08-11
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
#include <cyg/hal/hal_if.h>
67
 
68
#include <cyg/hal/plf_io.h>
69
 
70
const cyg_uint8 hal_diag_digits[] = {
71
        0x81, // 0
72
        0xf3, // 1
73
        0x49, // 2
74
        0x61, // 3
75
        0x33, // 4
76
        0x25, // 5
77
        0x05, // 6
78
        0xf1, // 7
79
        0x01, // 8
80
        0x21, // 9
81
        0x11, // A
82
        0x07, // B
83
        0x8d, // C
84
        0x43, // D
85
        0x0d, // E
86
        0x1d  // F
87
};
88
 
89
const char hal_diag_hex_digits[] = "0123456789ABCDEF";
90
 
91
cyg_uint32 hal_led_old_display = 0x5f17ffff; /* "rh  " */
92
 
93
/*------------------------------------------------------------------------*/
94
/* LED support                                                            */
95
cyg_uint8 cyg_hal_plf_led_val(CYG_WORD hexdig)
96
{
97
    return hal_diag_digits[(hexdig & 0xF)];
98
}
99
 
100
/*------------------------------------------------------------------------*/
101
 
102
#include CYGHWR_MEMORY_LAYOUT_H
103
#if defined(CYGPKG_CYGMON)
104
extern unsigned long cygmon_memsize;
105
#endif
106
 
107
void hal_platform_init(void)
108
{
109
    *(cyg_uint8*)(&hal_led_old_display) = cyg_hal_plf_led_val(8);
110
    HAL_WRITE_UINT32(HAL_LED_ADDRESS,hal_led_old_display);
111
 
112
#if defined(CYG_HAL_STARTUP_ROM)
113
    // Note that the hardware seems to come up with the
114
    // caches containing random data. Hence they must be
115
    // invalidated before being enabled.
116
    // However, we only do this if we are in ROM. If we are
117
    // in RAM, then we leave the caches in the state chosen
118
    // by the ROM monitor. If we enable them when the monitor
119
    // is not expecting it, we can end up breaking things if the
120
    // monitor is not doing cache flushes.
121
 
122
    HAL_ICACHE_INVALIDATE_ALL();
123
    HAL_ICACHE_ENABLE();
124
    HAL_DCACHE_INVALIDATE_ALL();
125
    HAL_DCACHE_ENABLE();
126
#endif
127
 
128
#if defined(CYGPKG_CYGMON)
129
    cygmon_memsize = 16 * 1024 * 1024 - 0x200;  // 16 MB - 0x200 (for _hal_vsr_table and _hal_virtual_vector_table)
130
#endif
131
 
132
    // Set up eCos/ROM interfaces
133
    hal_if_init();
134
 
135
#if defined(CYGPKG_KERNEL)                      && \
136
    defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT)   && \
137
    defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs)
138
    {
139
        extern CYG_ADDRESS hal_virtual_vector_table[32];
140
        extern void patch_dbg_syscalls(void * vector);
141
        patch_dbg_syscalls( (void *)(&hal_virtual_vector_table[0]) );
142
    }
143
#endif    
144
#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
145
    {
146
        static void hal_ctrlc_isr_init(void);
147
        hal_ctrlc_isr_init();
148
    }
149
#endif    
150
 
151
    // Make sure the TBR points at the base of ROM
152
#if 0
153
    {
154
        #define TBR 0xC0000024
155
        cyg_uint32 TBR_val;
156
        HAL_READ_UINT32(TBR, TBR_val);
157
        TBR_val = (TBR_val & 0x00FFFFFF) | 0x90000000; //(CYGMEM_REGION_rom & 0xFF000000);
158
        HAL_WRITE_UINT32(TBR, TBR_val);
159
    }
160
#endif
161
 
162
    // Make sure the MTBR points at the base of ROM
163
#if 0
164
    {
165
        #define mTBR 0xC0000028
166
        cyg_uint32 mTBR_val;
167
        HAL_READ_UINT32(mTBR, mTBR_val);
168
        mTBR_val = (mTBR_val & 0x00FFFFFF) | (CYGMEM_REGION_rom & 0xFF000000);
169
        HAL_WRITE_UINT32(mTBR, mTBR_val);
170
    }
171
#endif
172
}
173
 
174
/*------------------------------------------------------------------------*/
175
/* Functions to support the detection and execution of a user provoked    */
176
/* program break. These are usually called from interrupt routines.       */
177
 
178
/*------------------------------------------------------------------------*/
179
/* Control C ISR support                                                  */
180
#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
181
 
182
#if CYGHWR_HAL_MN10300_AM33_STB_GDB_PORT == 0
183
 
184
// We use serial0 on AM33
185
#define SERIAL_CR       ((volatile cyg_uint16 *)0xd4002000)
186
#define SERIAL_ICR      ((volatile cyg_uint8 *) 0xd4002004)
187
#define SERIAL_TXR      ((volatile cyg_uint8 *) 0xd4002008)
188
#define SERIAL_RXR      ((volatile cyg_uint8 *) 0xd4002009)
189
#define SERIAL_SR       ((volatile cyg_uint16 *)0xd400200c)
190
 
191
// Timer 1 provided baud rate divisor
192
#define TIMER_MD       ((volatile cyg_uint8 *)0xd4003000)
193
#define TIMER_BR       ((volatile cyg_uint8 *)0xd4003010)
194
#define TIMER_CR       ((volatile cyg_uint8 *)0xd4003020)
195
 
196
#define SIO_LSTAT_TRDY  0x20
197
#define SIO_LSTAT_RRDY  0x10
198
 
199
#else
200
 
201
#error Unsupported GDB port
202
 
203
#endif
204
 
205
struct Hal_SavedRegisters *hal_saved_interrupt_state;
206
 
207
static void hal_ctrlc_isr_init(void)
208
{
209
//    cyg_uint16 cr;
210
 
211
//    HAL_READ_UINT16( SERIAL_CR, cr );
212
//    cr |= LCR_RXE;
213
//    HAL_WRITE_UINT16( SERIAL_CR, cr );
214
    HAL_INTERRUPT_SET_LEVEL( CYGHWR_HAL_GDB_PORT_VECTOR, 4 );
215
    HAL_INTERRUPT_UNMASK( CYGHWR_HAL_GDB_PORT_VECTOR );
216
}
217
 
218
cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
219
{
220
    char c;
221
    cyg_uint16 sr;
222
 
223
    HAL_INTERRUPT_ACKNOWLEDGE( CYGHWR_HAL_GDB_PORT_VECTOR );
224
 
225
    HAL_READ_UINT16( SERIAL_SR, sr );
226
 
227
    if( sr & SIO_LSTAT_RRDY )
228
    {
229
        HAL_READ_UINT8( SERIAL_RXR, c);
230
 
231
        if( cyg_hal_is_break( &c , 1 ) )
232
            cyg_hal_user_break( (CYG_ADDRWORD *)hal_saved_interrupt_state );
233
 
234
 
235
    }
236
    return 1;
237
}
238
 
239
#endif
240
 
241
void hal_arch_funcall_new_stack(void (*func)(void), void* stack_base, cyg_uint32 stack_size)
242
{
243
    register cyg_uint32 stack_top = (cyg_uint32)stack_base + stack_size;
244
    register cyg_uint32 old_stack;
245
    asm volatile (" mov sp, %0" : "=r" (old_stack) : );
246
    asm volatile (" mov %0, sp" : : "r" (stack_top) );
247
    func();
248
    asm volatile (" mov %0, sp" : : "r" (old_stack) );
249
}
250
 
251
/*------------------------------------------------------------------------*/
252
/* Syscall support                                                        */
253
#ifdef CYGPKG_CYGMON
254
// Cygmon provides syscall handling for this board
255
#include <cyg/hal/hal_stub.h>
256
int __get_syscall_num (void)
257
{
258
    return SIGSYS;
259
}
260
#endif
261
 
262
/*------------------------------------------------------------------------*/
263
/* flash write-protect support                                            */
264
int plf_flash_query_soft_wp(void *addr, int len)
265
{
266
    if (((unsigned long)addr & 0xFC000000UL) == 0x84000000UL)
267
        return !(*(cyg_uint8*)0xA6FA0000 & 0x02); // system flash
268
    else
269
        return 0; // boot prom
270
}
271
 
272
/*------------------------------------------------------------------------*/
273
/* 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.