1 /* Initialization code for coldfire boards.
3 * Copyright (c) 2006 CodeSourcery Inc
5 * The authors hereby grant permission to use, copy, modify, distribute,
6 * and license this software and its documentation for any purpose, provided
7 * that existing copyright notices are retained in all copies and that this
8 * notice is included verbatim in any distributions. No written agreement,
9 * license, or royalty fee is required for any of the authorized uses.
10 * Modifications to this software may be copyrighted by their authors
11 * and need not follow the licensing terms described here, provided that
12 * the new terms are clearly indicated on the first page of each file where
18 extern const int __interrupt_vector[];
19 extern void __reset (void);
21 extern const char __data_load[] __attribute__ ((aligned (4)));
22 extern char __data_start[] __attribute__ ((aligned (4)));
23 extern char __bss_start[] __attribute__ ((aligned (4)));
24 extern char __end[] __attribute__ ((aligned (4)));
26 extern void software_init_hook (void) __attribute__ ((weak));
27 extern void hardware_init_hook (void) __attribute__ ((weak));
28 extern void __INIT_SECTION__ (void);
29 extern void __FINI_SECTION__ (void);
31 extern int main (int, char **, char **);
33 /* This is called from a tiny assembly stub. */
34 void __start1 (void *heap_limit)
38 if (hardware_init_hook)
39 hardware_init_hook ();
41 /* Initialize memory */
42 if (__data_load != __data_start)
43 memcpy (__data_start, __data_load, __bss_start - __data_start);
44 memset (__bss_start, 0, __end - __bss_start);
46 __heap_limit = heap_limit;
48 if (software_init_hook)
49 software_init_hook ();
53 /* I'm not sure how useful it is to have a fini_section in an
55 atexit (__FINI_SECTION__);
57 ix = main (0, NULL, NULL);
64 /* A default hardware init hook. */
66 void __attribute__ ((weak)) hardware_init_hook (void)
69 __asm__ __volatile__ ("movec.l %0,%/vbr" :: "r" (__interrupt_vector));
71 #ifndef __mcf_family_5213
72 /* Flush & enable the caches */
73 #define CACR_CINV (1 << 24)
74 #define CACR_CENB (1 << 31)
75 __asm__ __volatile__ ("movec.l %0,%/cacr" :: "r" (CACR_CINV | CACR_CENB));
78 /* Should we drop into user mode here? */