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

4.104.114.95
Last change on this file since e13e90c was e13e90c, checked in by Joel Sherrill <joel.sherrill@…>, on 12/03/07 at 22:25:10

2007-12-03 Joel Sherrill <joel.sherrill@…>

  • console/console.c, startup/bspstart.c: Moved most of the remaining CPU Table fields to the Configuration Table. This included pretasking_hook, predriver_hook, postdriver_hook, idle_task, do_zero_of_workspace, extra_mpci_receive_server_stack, stack_allocate_hook, and stack_free_hook. As a side-effect of this effort some multiprocessing code was made conditional and some style clean up occurred.
  • Property mode set to 100644
File size: 3.3 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 *  The original table from the application and our copy of it with
27 *  some changes.
28 */
29
30extern rtems_configuration_table Configuration;
31
32rtems_configuration_table  BSP_Configuration;
33
34rtems_cpu_table Cpu_table;
35
36/*
37 *  Use the shared implementations of the following routines
38 */
39
40extern void bsp_postdriver_hook(void);
41extern void bsp_libc_init( void *, uint32_t, int );
42extern rtems_configuration_table  BSP_Configuration;
43
44#if 0
45extern char         _RAMBase[];
46extern char         _RAMSize[];
47extern char         _WorkspaceBase[];
48extern char         _HeapSize[];
49#else
50extern char __alt_heap_start[];
51#endif
52
53/*
54 *  Function:   bsp_pretasking_hook
55 *  Created:    95/03/10
56 *
57 *  Description:
58 *      BSP pretasking hook.  Called just before drivers are initialized.
59 *      Used to setup libc and install any BSP extensions.
60 *
61 *  NOTES:
62 *      Must not use libc (to do io) from here, since drivers are
63 *      not yet initialized.
64 *
65 */
66
67void bsp_pretasking_hook(void)
68{
69    unsigned long heapStart;
70#if 0
71    unsigned long heapSize = (unsigned long)_HeapSize;
72#endif
73    unsigned long ramSpace;
74
75    heapStart = (unsigned long)BSP_Configuration.work_space_start
76              + BSP_Configuration.work_space_size;
77
78    if (heapStart & (CPU_ALIGNMENT-1))
79        heapStart = (heapStart + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
80
81#if 0
82    ramSpace = (unsigned long)_RAMBase + (unsigned long)_RAMSize - heapStart;
83#else
84#if 0
85    ramSpace = SRAM_0_BASE
86             + (SRAM_0_SRAM_MEMORY_SIZE * SRAM_0_SRAM_MEMORY_UNITS)
87             - heapStart;
88#else
89    ramSpace = RAM_BASE + RAM_BYTES - heapStart;
90#endif
91#endif
92
93    /* TODO */
94    ramSpace -= 16384; /* Space for initial stack, not to be zeroed */
95
96#if 0
97    if (heapSize < 10)
98        heapSize = ramSpace;
99    else if (heapSize > ramSpace)
100        rtems_fatal_error_occurred (('H'<<24) | ('E'<<16) | ('A'<<8) | 'P');
101
102    bsp_libc_init((void *)heapStart, heapSize, 0);
103#else
104    bsp_libc_init((void *)heapStart, ramSpace, 0);
105#endif
106
107#ifdef RTEMS_DEBUG
108    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
109#endif
110}
111
112/*
113 *  bsp_start
114 *
115 *  This routine does the bulk of the system initialization.
116 */
117
118void bsp_start( void )
119{
120  /*
121   *  Need to "allocate" the memory for the RTEMS Workspace and
122   *  tell the RTEMS configuration where it is.  This memory is
123   *  not malloc'ed.  It is just "pulled from the air".
124   */
125
126#if 0
127  BSP_Configuration.work_space_start = (void *)_WorkspaceBase;
128#else
129  BSP_Configuration.work_space_start = (void *)__alt_heap_start;
130#endif
131
132  /*
133   *  initialize the CPU table for this BSP
134   */
135
136  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
137}
Note: See TracBrowser for help on using the repository browser.