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

4.104.114.84.95
Last change on this file since 783669fc was 783669fc, checked in by Joel Sherrill <joel.sherrill@…>, on 08/09/06 at 20:57:11

2006-08-09 Kolja Waschk <waschk@…>

  • ChangeLog?, Makefile.am, README, acinclude.m4, configure.ac, nios2_iss/ChangeLog, nios2_iss/Makefile.am, nios2_iss/bsp_specs, nios2_iss/configure.ac, nios2_iss/nios2_iss.ptf, nios2_iss/nios2_iss.sh, nios2_iss/times, nios2_iss/console/console.c, nios2_iss/include/bsp.h, nios2_iss/include/bspopts.h.in, nios2_iss/include/coverhd.h, nios2_iss/include/tm27.h, nios2_iss/shmsupp/addrconv.c, nios2_iss/shmsupp/getcfg.c, nios2_iss/shmsupp/lock.c, nios2_iss/shmsupp/mpisr.c, nios2_iss/start/crtnn.s, nios2_iss/start/start.S, nios2_iss/startup/bspclean.c, nios2_iss/startup/bspstart.c, nios2_iss/startup/linkcmds, nios2_iss/startup/main.c, nios2_iss/startup/setvec.c, nios2_iss/timer/timer.c: New files.
  • Property mode set to 100644
File size: 3.5 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  /* Fixed */
121
122  BSP_Configuration.microseconds_per_tick = 1000;
123
124  /*
125   *  Need to "allocate" the memory for the RTEMS Workspace and
126   *  tell the RTEMS configuration where it is.  This memory is
127   *  not malloc'ed.  It is just "pulled from the air".
128   */
129
130#if 0
131  BSP_Configuration.work_space_start = (void *)_WorkspaceBase;
132#else
133  BSP_Configuration.work_space_start = (void *)__alt_heap_start;
134#endif
135
136  /*
137   *  initialize the CPU table for this BSP
138   */
139
140  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
141  Cpu_table.postdriver_hook = bsp_postdriver_hook;
142  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
143}
Note: See TracBrowser for help on using the repository browser.