source: rtems/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c @ 6dacdf9d

4.104.114.84.9
Last change on this file since 6dacdf9d was 6dacdf9d, checked in by Joel Sherrill <joel.sherrill@…>, on May 11, 2007 at 9:19:23 PM

2007-05-11 Joel Sherrill <joel.sherrill@…>

  • include/bsp.h, startup/bspstart.c, startup/spurious.c: hello and ticker now run using runtest.
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *  This set of routines starts the application.  It includes application,
3 *  board, and monitor specific initialization and configuration.
4 *  The generic CPU dependent initialization has been performed
5 *  before any of these are invoked.
6 *
7 *  COPYRIGHT (c) 1989-2007.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  Modified for LEON3 BSP.
11 *  COPYRIGHT (c) 2004.
12 *  Gaisler Research.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21/* must be identical to STACK_SIZE in start.S */
22#define STACK_SIZE 16 * 1024
23
24#include <string.h>
25
26#include <bsp.h>
27#include <rtems/bspIo.h>
28
29/*
30 *  The original table from the application and our copy of it with
31 *  some changes.
32 */
33
34extern rtems_configuration_table  Configuration;
35rtems_configuration_table         BSP_Configuration;
36
37rtems_cpu_table Cpu_table;
38
39/*
40 *  Tells us where to put the workspace in case remote debugger is present.
41 */
42
43extern uint32_t rdb_start;
44
45void bsp_postdriver_hook(void);
46void bsp_libc_init( void *, uint32_t, int );
47extern void bsp_spurious_initialize();
48
49/*
50 *  bsp_pretasking_hook
51 *
52 *  BSP pretasking hook.  Called just before drivers are initialized.
53 *  Used to setup libc and install any BSP extensions.
54 */
55
56void bsp_pretasking_hook(void)
57{
58  extern int end;
59  uint32_t heap_start;
60  uint32_t heap_size;
61
62  heap_start = (uint32_t) &end;
63  if (heap_start & (CPU_ALIGNMENT-1))
64    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
65
66  heap_size = BSP_Configuration.work_space_start - (void *)&end - STACK_SIZE;
67  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
68
69  bsp_libc_init((void *) heap_start, heap_size, 0);
70
71#ifdef RTEMS_DEBUG
72  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
73#endif
74
75  bsp_spurious_initialize();
76}
77
78void bsp_leon3_predriver_hook(void);
79
80/*
81 *  bsp_start
82 *
83 *  This routine does the bulk of the system initialization.
84 */
85
86void bsp_start( void )
87{
88  unsigned char *work_space_start;
89
90  /*
91   * Set up our hooks
92   * Make sure libc_init is done before drivers initialized so that
93   * they can use atexit()
94   */
95
96  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
97  Cpu_table.postdriver_hook = bsp_postdriver_hook;
98  Cpu_table.predriver_hook = bsp_leon3_predriver_hook;     /* scan system bus */
99
100  /*
101   *  This should be enough interrupt stack.
102   */
103
104  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
105
106  work_space_start =
107    (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
108
109  if ( work_space_start <= (unsigned char *)&end ) {
110    printk( "bspstart: Not enough RAM!!!\n" );
111    BSP_fatal_return();
112  }
113
114  BSP_Configuration.work_space_start = work_space_start;
115}
Note: See TracBrowser for help on using the repository browser.