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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [m68k/] [arch/] [v2_0/] [src/] [hal_startup.c] - Blame information for rev 27

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

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//####ECOSGPLCOPYRIGHTBEGIN####
3
// -------------------------------------------
4
// This file is part of eCos, the Embedded Configurable Operating System.
5
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
6
//
7
// eCos is free software; you can redistribute it and/or modify it under
8
// the terms of the GNU General Public License as published by the Free
9
// Software Foundation; either version 2 or (at your option) any later version.
10
//
11
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
12
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
// for more details.
15
//
16
// You should have received a copy of the GNU General Public License along
17
// with eCos; if not, write to the Free Software Foundation, Inc.,
18
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19
//
20
// As a special exception, if other files instantiate templates or use macros
21
// or inline functions from this file, or you compile this file and link it
22
// with other works to produce a work based on this file, this file does not
23
// by itself cause the resulting work to be covered by the GNU General Public
24
// License. However the source code for this file must still be made available
25
// in accordance with section (3) of the GNU General Public License.
26
//
27
// This exception does not invalidate any other reasons why a work based on
28
// this file might be covered by the GNU General Public License.
29
//
30
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
31
// at http://sources.redhat.com/ecos/ecos-license/
32
// -------------------------------------------
33
//####ECOSGPLCOPYRIGHTEND####
34
//==========================================================================
35
 
36
#include <pkgconf/hal.h>
37
#include <cyg/hal/hal_startup.h>
38
#include <cyg/hal/hal_memmap.h>
39
#include <cyg/hal/hal_intr.h>
40
#include <cyg/hal/hal_diag.h>           // hal_diag_init
41
#include <cyg/infra/diag.h>             // diag_printf
42
#include <string.h>                     // memcpy, memset
43
 
44
externC void cyg_start(void);
45
externC void hw_vsr_reset(void);
46
 
47
#define CYG_HAL_RESET_DEBUG_ENABLE
48
#ifdef CYG_HAL_RESET_DEBUG_ENABLE
49
#define CYG_HAL_RESET_DEBUG diag_printf
50
#else
51
#define CYG_HAL_RESET_DEBUG()
52
#endif // CYG_HAL_RESET_DEBUG_ENABLE
53
 
54
/*****************************************************************************
55
hal_vsr_init -- Initialize the vector table
56
 
57
INPUT:
58
 
59
OUTPUT:
60
 
61
RETURN VALUE:
62
 
63
     None
64
 
65
*****************************************************************************/
66
static void hal_vsr_init(void)
67
{
68
 
69
    /*   Initialize the HAL's vector table with the ROM vector table.       */
70
 
71
    memcpy((void*)cyg_hal_vsr_table, __romvec_start,
72
                (size_t)sizeof(cyg_hal_vsr_table));
73
 
74
}
75
 
76
/*****************************************************************************
77
hal_vsr_init -- Initialize the ISRs
78
 
79
INPUT:
80
 
81
OUTPUT:
82
 
83
RETURN VALUE:
84
 
85
     None
86
 
87
*****************************************************************************/
88
static void hal_isr_init(void)
89
{
90
    int_t i;
91
 
92
    //   Initialize all ISR entries to default.
93
 
94
    for (i = 0; i < CYGNUM_HAL_ISR_COUNT; i++)
95
    {
96
        cyg_hal_interrupt_handlers[i] = (CYG_ADDRESS) &hal_default_isr;
97
        cyg_hal_interrupt_data[i] = (CYG_ADDRWORD)0;
98
        cyg_hal_interrupt_objects[i] = (CYG_ADDRESS)0;
99
    }
100
}
101
 
102
/*****************************************************************************
103
hal_init_ram_sections -- Initialize the RAM sections
104
 
105
     Initialize all RAM sections that  the C  code relies  on.  data,  bss,
106
sbss.
107
 
108
INPUT:
109
 
110
OUTPUT:
111
 
112
RETURN VALUE:
113
 
114
     None
115
 
116
*****************************************************************************/
117
static void hal_init_ram_sections(void)
118
{
119
 
120
    //   Initialize the RAM data section  from  the  ROM  image  of  the  data
121
    // section.
122
 
123
    memcpy(__ram_data_start, __rom_data_start, (size_t)__ram_data_size);
124
 
125
    //   Initialize the bss and sbss sections to zero.
126
 
127
    memset(__bss_start, 0, (size_t)__bss_size);
128
    memset(__sbss_start, 0, (size_t)__sbss_size);
129
}
130
 
131
/*****************************************************************************
132
cyg_hal_invoke_constructors -- Call static constructors
133
 
134
INPUT:
135
 
136
OUTPUT:
137
 
138
RETURN VALUE:
139
 
140
     None
141
 
142
*****************************************************************************/
143
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
144
cyg_bool cyg_hal_stop_constructors;
145
#endif
146
 
147
typedef void (*pfunc) (void);
148
extern pfunc __CTOR_LIST__[];
149
extern pfunc __CTOR_END__[];
150
 
151
static void cyg_hal_invoke_constructors(void)
152
{
153
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
154
    static pfunc *p = &__CTOR_END__[-1];
155
 
156
    cyg_hal_stop_constructors = 0;
157
    for (; p >= __CTOR_LIST__; p--) {
158
        (*p) ();
159
        if (cyg_hal_stop_constructors) {
160
            p--;
161
            break;
162
        }
163
    }
164
#else
165
    pfunc *p;
166
 
167
    for (p = &__CTOR_END__[-1]; p >= __CTOR_LIST__; p--)
168
        (*p) ();
169
#endif
170
}
171
 
172
/*****************************************************************************
173
hal_reset -- Reset vector routine
174
 
175
     This routine must be  called with interrupts  disabled and will  never
176
return.
177
 
178
     Only the assembly reset vector routine should call this routine.
179
 
180
INPUT:
181
 
182
OUTPUT:
183
 
184
RETURN VALUE:
185
 
186
     None
187
 
188
*****************************************************************************/
189
void hal_reset(void) CYGBLD_ATTRIB_NORET;
190
void hal_reset(void)
191
{
192
    const char * fname;
193
 
194
    fname = __FUNCTION__;
195
 
196
    //   Initialize the RAM sections that the rest of the C code requires.
197
 
198
    hal_init_ram_sections();
199
 
200
    //   It is now safe  to call  C functions  which may  rely on  initialized
201
    // data.
202
 
203
    //   Initialize the ISR and VSR tables.
204
 
205
    hal_isr_init();
206
    hal_vsr_init();
207
 
208
    //   Do any variant-specific reset initialization.
209
 
210
    var_reset();
211
 
212
    //   Initialize the diagnostics IO.
213
 
214
    HAL_DIAG_INIT();
215
    CYG_HAL_RESET_DEBUG("%s: RESET\r\n", fname);
216
 
217
    //   Call C++ constructors.
218
 
219
    CYG_HAL_RESET_DEBUG("%s: calling cyg_hal_invoke_constructors\r\n", fname);
220
    cyg_hal_invoke_constructors();
221
 
222
    //   It should be safe to enable interrupts now.
223
 
224
    CYG_HAL_RESET_DEBUG("%s: lowering interrupt mask\r\n", fname);
225
    HAL_ENABLE_INTERRUPTS();
226
 
227
    //   Call cyg_start.  This routine should not return.
228
 
229
    CYG_HAL_RESET_DEBUG("%s: calling cyg_start\r\n", fname);
230
    cyg_start();
231
 
232
    //   If we return, loop and print out a message.
233
 
234
    HAL_DIAG_INIT();
235
    for (;;)
236
    {
237
        CYG_HAL_RESET_DEBUG("%s: cyg_start returned!\r\n", fname);
238
    }
239
}
240
 
241
/*****************************************************************************
242
hal_hw_reset -- Simulate a hardware reset
243
 
244
     This routine will never return.
245
 
246
INPUT:
247
 
248
OUTPUT:
249
 
250
RETURN VALUE:
251
 
252
     None
253
 
254
*****************************************************************************/
255
void hal_hw_reset(void)
256
{
257
 
258
    //   Give control to the reset vector handler.
259
 
260
    hw_vsr_reset();
261
}
262
 

powered by: WebSVN 2.1.0

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