source: rtems/c/src/lib/libbsp/arm/edb7312/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: 6.8 KB
Line 
1/*
2 * Cirrus EP7312 Startup code
3 *
4 * Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com>
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *
12 *  $Id$
13*/
14
15#include <bsp.h>
16#include <rtems/libcsupport.h>
17#include <rtems/libio.h>
18#include <ep7312.h>
19#include <uart.h>
20
21/*************************************************************/
22/* Macros                                                    */
23/*************************************************************/
24
25/*************************************************************/
26/* Data Structures                                           */
27/*************************************************************/
28
29/*************************************************************/
30/* Global Variables                                          */
31/*************************************************************/
32extern void            *_flash_size;
33extern void            *_flash_base;
34extern void            *_sdram_size;
35extern void            *_sdram_base;
36extern void            *_bss_free_start;
37
38unsigned long           free_mem_start;
39unsigned long           free_mem_end;
40
41/*************************************************************/
42/* Function prototypes                                       */
43/*************************************************************/
44extern void rtems_irq_mngt_init(void);
45void bsp_libc_init( void *, uint32_t, int );
46
47/**************************************************************************/
48/*                                                                        */
49/* NAME: bps_pretasking_hook - Function to setup system before startup    */
50/*                                                                        */
51/* DESCRIPTION:                                                           */
52/*   This function is called before drivers are initialized and used      */
53/*   to setup libc and BSP extensions. It configures non cacheable        */
54/*   SDRAM, SRAM, AIM, and ADM regions and sets up the CPU's memory       */
55/*   protection unit.                                                     */
56/*                                                                        */
57/* GLOBALS USED:                                                          */
58/*   free_mem_start                                                 */
59/*   free_mem_end                                                   */
60/*                                                                        */
61/* RESTRICTIONS/LIMITATIONS:                                              */
62/*   Since this function is setting up libc, it cannot use and libc       */
63/*   functions.                                                           */
64/*                                                                        */
65/**************************************************************************/
66void bsp_pretasking_hook(void)
67{
68    uint32_t   heap_start;
69    uint32_t   heap_size;
70
71    /*
72     * Set up the heap. It uses all free SDRAM except that reserved
73     * for non-cached uses.
74     */
75    heap_start =  free_mem_start;
76
77    /*   heap_size = (free_mem_end - heap_start - MEM_NOCACHE_SIZE); */
78    heap_size = 0x200000;
79
80    bsp_libc_init((void *)heap_start, heap_size, 0);
81
82#ifdef RTEMS_DEBUG
83
84  rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
85
86#endif /* RTEMS_DEBUG */
87
88} /* bsp_pretasking_hook */
89
90/**************************************************************************/
91/*                                                                        */
92/* NAME: bsp_start_default - BSP initialization function                  */
93/*                                                                        */
94/* DESCRIPTION:                                                           */
95/*   This function is called before RTEMS is initialized and used         */
96/*   adjust the kernel's configuration.                                   */
97/*                                                                        */
98/*   This function also configures the CPU's memory protection unit.      */
99/*                                                                        */
100/* GLOBALS USED:                                                          */
101/*    CPU_table                                                           */
102/*    Configuration                                                       */
103/*    free_mem_start                                                      */
104/*    free_mem_end                                                        */
105/*    free_mem_nocache_start                                              */
106/*    _bss_free_start                                                     */
107/*    mpu_region_tbl                                                      */
108/*                                                                        */
109/*                                                                        */
110/*                                                                        */
111/*                                                                        */
112/* RESTRICTIONS/LIMITATIONS:                                              */
113/*   Since RTEMS is not configured, no RTEMS functions can be called.     */
114/*                                                                        */
115/**************************************************************************/
116void bsp_start_default( void )
117{
118    /* disable interrupts */
119    *EP7312_INTMR1 = 0;
120    *EP7312_INTMR2 = 0;
121
122    /* Place RTEMS workspace at beginning of free memory. */
123    Configuration.work_space_start = (void *)&_bss_free_start;
124
125    free_mem_start = ((uint32_t)&_bss_free_start +
126                      rtems_configuration_get_work_space_size());
127
128    free_mem_end = ((uint32_t)&_sdram_base + (uint32_t)&_sdram_size);
129
130    /*
131     * Init rtems exceptions management
132     */
133    rtems_exception_init_mngt();
134
135    /*
136     * Init rtems interrupt management
137     */
138    rtems_irq_mngt_init();
139
140    /*
141     *  The following information is very useful when debugging.
142     */
143#if 0
144    printk( "work_space_size = 0x%x\n",
145            rtems_configuration_get_work_space_size() );
146    printk( "microseconds_per_tick = 0x%x\n",
147            rtems_configuration_get_microseconds_per_tick() );
148    printk( "ticks_per_timeslice = 0x%x\n",
149            rtems_configuration_get_ticks_per_timeslice() );
150
151    /*  printk( "_stack_size = 0x%x\n", _stack_size );*/
152    printk( "work_space_start = 0x%x\n", Configuration.work_space_start );
153    printk( "work_space_size = 0x%x\n", rtems_configuration_get_work_space_size() );
154#endif
155} /* bsp_start */
156
157/*
158 *  By making this a weak alias for bsp_start_default, a brave soul
159 *  can override the actual bsp_start routine used.
160 */
161
162void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
Note: See TracBrowser for help on using the repository browser.