source: trunk/libs/newlib/src/libgloss/m68k/cf-crt1.c @ 495

Last change on this file since 495 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.3 KB
Line 
1/* Initialization code for coldfire boards.
2 *
3 * Copyright (c) 2006 CodeSourcery Inc
4 *
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
13 * they apply.
14 */
15
16#include <stdlib.h>
17
18extern const int __interrupt_vector[];
19extern void __reset (void);
20
21extern const char __data_load[] __attribute__ ((aligned (4)));
22extern char __data_start[] __attribute__ ((aligned (4)));
23extern char __bss_start[] __attribute__ ((aligned (4)));
24extern char __end[] __attribute__ ((aligned (4)));
25void *__heap_limit;
26extern void software_init_hook (void) __attribute__ ((weak));
27extern void hardware_init_hook (void) __attribute__ ((weak));
28extern void _init (void);
29extern void _fini (void);
30
31extern int main (int, char **, char **);
32
33/* This is called from a tiny assembly stub.  */
34void __start1 (void *heap_limit)
35{
36  unsigned ix;
37 
38  if (hardware_init_hook)
39    hardware_init_hook ();
40 
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);
45 
46  __heap_limit = heap_limit;
47 
48  if (software_init_hook)
49    software_init_hook ();
50
51  _init ();
52
53  /* I'm not sure how useful it is to have a fini_section in an
54     embedded system.  */
55  atexit (_fini);
56 
57  ix = main (0, NULL, NULL);
58  exit (ix);
59 
60  while (1)
61    __reset ();
62}
63
64/* A default hardware init hook.  */
65
66void __attribute__ ((weak)) hardware_init_hook (void)
67{
68  /* Set the VBR. */
69  __asm__ __volatile__ ("movec.l %0,%/vbr" :: "r" (__interrupt_vector));
70
71#if !defined(__mcf_family_5213) && !defined(__mcf_family_51qe) && !defined(__mcf_family_51)
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));
76#endif
77
78  /* Should we drop into user mode here? */
79}
Note: See TracBrowser for help on using the repository browser.