source: rtems/c/src/lib/libbsp/powerpc/mvme2307/startup/bspstart.c @ 19ca797

4.104.114.84.95
Last change on this file since 19ca797 was 19ca797, checked in by Joel Sherrill <joel.sherrill@…>, on 10/04/99 at 20:41:28

Motorola MVME2307 BSP submitted by Jay Kulpinski <jskulpin@…>.
No modifications made.

  • Property mode set to 100644
File size: 3.6 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-1998.
8 *  On-Line Applications Research Corporation (OAR).
9 *  All rights assigned to U.S. Government, 1994.
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.OARcorp.com/rtems/license.html.
14 *
15 *  $Id$
16 */
17
18#include <bsp.h>
19#include <rtems/libio.h>
20
21#include <libcsupport.h>
22
23#include <string.h>
24#include <fcntl.h>
25
26/*
27 *  The original table from the application and our copy of it with
28 *  some changes.
29 */
30 
31rtems_configuration_table         BSP_Configuration;
32
33rtems_cpu_table   Cpu_table;
34
35
36
37/*
38 *  Use the shared implementations of the following routines
39 */
40 
41void bsp_postdriver_hook(void);
42void bsp_libc_init( void *, unsigned32, int );
43
44/*
45 *  bsp_pretasking_hook
46 *
47 *  BSP pretasking hook.  Called just before drivers are initialized.
48 *  Used to setup libc and install any BSP extensions.
49 */
50
51void bsp_pretasking_hook(void)
52{
53    extern int end;
54    rtems_unsigned32 heap_start;
55    rtems_unsigned32 heap_size;
56    rtems_isr_entry old_handler;
57    rtems_status_code sc;
58
59    heap_start = (rtems_unsigned32) &end;
60    if (heap_start & (CPU_ALIGNMENT-1)) {
61        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
62    }
63
64    heap_size = BSP_Configuration.work_space_start - (void *)&end;
65    heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
66
67    bsp_libc_init((void *) heap_start, heap_size, 0);
68
69    sc = interrupt_controller_init();
70
71
72
73#ifdef RTEMS_DEBUG
74    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
75#endif
76
77}
78
79/*
80 *  bsp_start
81 *
82 *  This routine does the bulk of the system initialization.
83 */
84
85void bsp_start( void )
86{
87    unsigned char *work_space_start;
88    unsigned32 RAM_end = 0;
89
90#if 1
91    /*
92    * Set MSR to show vectors at 0 XXX
93    */
94    rtems_unsigned32 msr_value;
95
96    _CPU_MSR_Value( msr_value );
97    msr_value &= ~PPC_MSR_EP;
98    _CPU_MSR_SET( msr_value );
99#endif
100
101    /*
102    * Set up our hooks
103    * Make sure libc_init is done before drivers initialized so that
104    * they can use atexit()
105    */
106
107    Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
108    Cpu_table.postdriver_hook = bsp_postdriver_hook;
109
110    Cpu_table.interrupt_stack_size = (12 * 1024);
111
112    /*
113    *  The monitor likes the exception table to be at 0x0.
114    */
115
116    Cpu_table.exceptions_in_RAM = TRUE;
117
118    /*
119    #if defined(RTEMS_POSIX_API)
120    BSP_Configuration.work_space_size *= 3;
121    #endif
122    */
123
124    /* from PSIM - why? */
125    BSP_Configuration.work_space_size += 1024;
126
127    /* determine memory size */
128    switch (Falcon_MEMCR.MemSize) {
129        case RAM_16_MB:
130            RAM_end = 16 * 1024 * 1024;
131            break;
132        case RAM_32_MB:
133            RAM_end = 32 * 1024 * 1024;
134            break;
135        case RAM_64_MB:
136            RAM_end = 64 * 1024 * 1024;
137            break;
138        case RAM_128_MB:
139            RAM_end = 128 * 1024 * 1024;
140            break;
141    }
142    RAM_end -= 1024 * 1024;  /* reserve memory for PPCBUG */
143    work_space_start =
144            (unsigned char *)RAM_end - BSP_Configuration.work_space_size;
145
146    if ( work_space_start <= (unsigned char *)&end ) {
147        printk( "bspstart: Not enough RAM!!!\n" );
148        bsp_cleanup();
149    }
150
151    BSP_Configuration.work_space_start = work_space_start;
152
153    /*
154    *  Account for the console's resources
155    */
156
157    console_reserve_resources( &BSP_Configuration );
158
159}
Note: See TracBrowser for help on using the repository browser.