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

Subversion Repositories openrisc_me

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

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