source: rtems/c/src/lib/libbsp/nios2/nios2_iss/startup/bspstart.c @ 6ea100c1

4.104.114.95
Last change on this file since 6ea100c1 was 6ea100c1, checked in by Joel Sherrill <joel.sherrill@…>, on 05/12/08 at 18:43:55

2008-05-12 Joel Sherrill <joel.sherrill@…>

  • startup/bspstart.c: Refactored and renamed initialization routines to rtems_initialize_data_structures, rtems_initialize_before_drivers, rtems_initialize_device_drivers, and rtems_initialize_start_multitasking. This opened the sequence up so that bootcard() could provide a more robust and flexible framework which is easier to explain and understand. This also lays the groundwork for sharing the division of available memory between the RTEMS workspace and heap and the C library initialization across all BSPs.
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 *  This routine 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 this routine is invoked.
6 *
7 *  COPYRIGHT (c) 2005-2006 Kolja Waschk rtemsdev/ixo.de
8 *  Derived from no_cpu/no_bsp/startup/bspstart.c 1.23.
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#include <string.h>
20
21#include <bsp.h>
22#include <rtems/libio.h>
23#include <rtems/libcsupport.h>
24
25/*
26 *  Use the shared implementations of the following routines
27 */
28
29extern void bsp_libc_init( void *, uint32_t, int );
30
31#if 0
32extern char         _RAMBase[];
33extern char         _RAMSize[];
34extern char         _WorkspaceBase[];
35extern char         _HeapSize[];
36#else
37extern char __alt_heap_start[];
38#endif
39
40/*
41 *  Function:   bsp_pretasking_hook
42 *  Created:    95/03/10
43 *
44 *  Description:
45 *      BSP pretasking hook.  Called just before drivers are initialized.
46 *      Used to setup libc and install any BSP extensions.
47 *
48 *  NOTES:
49 *      Must not use libc (to do io) from here, since drivers are
50 *      not yet initialized.
51 *
52 */
53
54void bsp_pretasking_hook(void)
55{
56    unsigned long heapStart;
57#if 0
58    unsigned long heapSize = (unsigned long)_HeapSize;
59#endif
60    unsigned long ramSpace;
61
62    heapStart = (unsigned long)Configuration.work_space_start
63              + rtems_configuration_get_work_space_size();
64
65    if (heapStart & (CPU_ALIGNMENT-1))
66        heapStart = (heapStart + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
67
68#if 0
69    ramSpace = (unsigned long)_RAMBase + (unsigned long)_RAMSize - heapStart;
70#else
71#if 0
72    ramSpace = SRAM_0_BASE
73             + (SRAM_0_SRAM_MEMORY_SIZE * SRAM_0_SRAM_MEMORY_UNITS)
74             - heapStart;
75#else
76    ramSpace = RAM_BASE + RAM_BYTES - heapStart;
77#endif
78#endif
79
80    /* TODO */
81    ramSpace -= 16384; /* Space for initial stack, not to be zeroed */
82
83#if 0
84    if (heapSize < 10)
85        heapSize = ramSpace;
86    else if (heapSize > ramSpace)
87        rtems_fatal_error_occurred (('H'<<24) | ('E'<<16) | ('A'<<8) | 'P');
88
89    bsp_libc_init((void *)heapStart, heapSize, 0);
90#else
91    bsp_libc_init((void *)heapStart, ramSpace, 0);
92#endif
93
94#ifdef RTEMS_DEBUG
95    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
96#endif
97}
98
99/*
100 *  bsp_start
101 *
102 *  This routine does the bulk of the system initialization.
103 */
104
105void bsp_start( void )
106{
107  /*
108   *  Need to "allocate" the memory for the RTEMS Workspace and
109   *  tell the RTEMS configuration where it is.  This memory is
110   *  not malloc'ed.  It is just "pulled from the air".
111   */
112
113#if 0
114  Configuration.work_space_start = (void *)_WorkspaceBase;
115#else
116  Configuration.work_space_start = (void *)__alt_heap_start;
117#endif
118
119}
Note: See TracBrowser for help on using the repository browser.