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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [sparclite/] [arch/] [current/] [src/] [hal_boot.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      hal_boot.c
4
//
5
//      SPARClite Architecture specific interrupt dispatch tables
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 Free Software Foundation, 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      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    hmt
43
// Contributors: hmt
44
// Date:         1998-12-10
45
// Purpose:      Interrupt handler tables for SPARClite.
46
//              
47
//####DESCRIPTIONEND####
48
//
49
//==========================================================================
50
 
51
#include <pkgconf/hal.h>
52
#include <cyg/infra/cyg_type.h>
53
 
54
/*------------------------------------------------------------------------*/
55
/* calling this is our raison d'etre: */
56
extern void cyg_start( void );
57
 
58
/*------------------------------------------------------------------------*/
59
/* data copy and bss zero functions                                       */
60
 
61
typedef void (CYG_ROM_ADDRESS)(void);
62
 
63
#ifdef CYG_HAL_STARTUP_ROM      
64
void hal_copy_data(void)
65
{
66
    extern char __ram_data_start;
67
    extern char __ram_data_end;
68
    extern CYG_ROM_ADDRESS __rom_data_start;
69
    long *p = (long *)&__ram_data_start;
70
    long *q = (long *)&__rom_data_start;
71
 
72
    while( p <= (long *)&__ram_data_end )
73
        *p++ = *q++;
74
}
75
#endif
76
 
77
void hal_zero_bss(void)
78
{
79
    extern CYG_ROM_ADDRESS __bss_start;
80
    extern CYG_ROM_ADDRESS __bss_end;
81
 
82
    register long long zero = 0;
83
    register long long *end = (long long *)&__bss_end;
84
    register long long *p = (long long *)&__bss_start;
85
 
86
    while( p <= end )
87
        *p++ = zero;
88
}
89
 
90
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
91
cyg_bool cyg_hal_stop_constructors;
92
#endif
93
 
94
void
95
cyg_hal_invoke_constructors (void)
96
{
97
    typedef void (*pfunc) (void);
98
    extern pfunc __CTOR_LIST__[];
99
    extern pfunc __CTOR_END__[];
100
 
101
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
102
    static pfunc *p = &__CTOR_END__[-1];
103
 
104
    cyg_hal_stop_constructors = 0;
105
    for (; p >= __CTOR_LIST__; p--) {
106
        (*p) ();
107
        if (cyg_hal_stop_constructors) {
108
            p--;
109
            break;
110
        }
111
    }
112
#else
113
    pfunc *p;
114
 
115
    for (p = &__CTOR_END__[-1]; p >= __CTOR_LIST__; p--)
116
        (*p) ();
117
#endif
118
}
119
 
120
// Override any __gccmain the compiler might generate. We don't want
121
// constructors to be called twice.
122
void  __gccmain(void) {}
123
 
124
/*------------------------------------------------------------------------*/
125
/*   CYG_HAL_START - pre-main-entrypoint                                  */
126
 
127
#ifdef CYGPKG_HAL_SPARCLITE_SLEB
128
#define SLEB_LED (*(volatile char *)(0x02000003))
129
#define LED( _x_ ) SLEB_LED = (char)(0xff & ~(_x_))
130
#else
131
#define LED( _x_ ) CYG_EMPTY_STATEMENT
132
#endif
133
 
134
extern void hal_board_prestart( void );
135
extern void hal_board_poststart( void );
136
 
137
// This is called with traps enabled, but interrupts masked out:
138
// Be sure to enable them in hal_board_poststart() at the latest.
139
 
140
void cyg_hal_start( void )
141
{
142
    /* Board specific prestart that's best done in C */
143
    hal_board_prestart();
144
 
145
    LED( 0xd0 );
146
 
147
#ifdef CYG_HAL_STARTUP_ROM
148
    /* Copy data from ROM to RAM */
149
    hal_copy_data();
150
#endif
151
 
152
    LED( 0xd4 );
153
 
154
    /* Zero BSS */
155
    hal_zero_bss();
156
 
157
    LED( 0xd8 );
158
 
159
    /* Call constructors */
160
    cyg_hal_invoke_constructors();
161
 
162
    LED( 0xdc );
163
 
164
    /* Board specific late startup that's best done in C */
165
    hal_board_poststart();
166
 
167
    LED( 0xf8 );
168
 
169
    /* Call cyg_start */
170
    cyg_start(); /* does not return */
171
}
172
 
173
// EOF hal_boot.c

powered by: WebSVN 2.1.0

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