source: rtems/c/src/lib/libbsp/powerpc/dmv177/startup/bspstart.c @ dc104a4

4.104.114.84.95
Last change on this file since dc104a4 was dc104a4, checked in by Joel Sherrill <joel.sherrill@…>, on May 30, 1998 at 11:46:21 AM

Updated to current source and removed warnings.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*  bspstart.c
2 *
3 *  This set of routines starts the application.  It includes application,
4 *  board, and monitor specific initialization and configuration.
5 *  The generic CPU dependent initialization has been performed
6 *  before any of these are invoked.
7 *
8 *  Called by RTEMS::RTEMS constructor in rtems-ctor.cc
9 *
10 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994, 1997.
11 *  On-Line Applications Research Corporation (OAR).
12 *  All rights assigned to U.S. Government, 1994.
13 *
14 *  $Id$
15 */
16
17#include <bsp.h>
18#include <rtems/libio.h>
19
20#include <libcsupport.h>
21
22#include <string.h>
23
24/*
25 *  The original table from the application and our copy of it with
26 *  some changes.
27 */
28 
29extern rtems_configuration_table  Configuration;
30rtems_configuration_table         BSP_Configuration;
31rtems_cpu_table                   Cpu_table;
32rtems_unsigned32                  bsp_isr_level;
33
34/*
35 *  Use the shared implementations of the following routines
36 */
37
38void bsp_postdriver_hook(void);
39void bsp_libc_init( void *, unsigned32, int );
40
41/*PAGE
42 *
43 *  bsp_pretasking_hook
44 *
45 *  BSP pretasking hook.  Called just before drivers are initialized.
46 *  Used to setup libc and install any BSP extensions.
47 */
48
49void bsp_pretasking_hook(void)
50{
51  extern int end;
52  rtems_unsigned32 heap_start;
53  rtems_unsigned32 heap_size;
54
55  heap_start = (rtems_unsigned32) &end;
56  if (heap_start & (CPU_ALIGNMENT-1))
57    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
58
59  heap_size = BSP_Configuration.work_space_start - (void *)&end;
60  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
61
62  bsp_libc_init((void *) heap_start, heap_size, 0);
63
64#ifdef RTEMS_DEBUG
65  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
66#endif
67
68}
69
70/*  PAGE
71 *
72 *  bsp_predriver_hook
73 *
74 *  Initialization before drivers are setup.
75 *  Input parameters: NONE
76 *
77 *  Output parameters:  NONE
78 *
79 *  Return values: NONE
80 */ 
81
82void bsp_predriver_hook(void)
83{
84  initialize_external_exception_vector();
85}
86
87/*PAGE
88 *
89 *  bsp_start
90 *
91 *  This routine does the bulk of the system initialization.
92 */
93
94void bsp_start( void )
95{
96  unsigned char *work_space_start;
97  unsigned int  msr_value = 0x2030;
98
99  /*
100   * Set BSP to initial value. Note: This value is a guess
101   * check how the real board comes up. This is critical to
102   * getting the source to work with the debugger.
103   */
104
105  _CPU_MSR_SET( msr_value );
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  work_space_start = 
114    (unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
115
116  if ( work_space_start <= (unsigned char *)&end ) {
117    DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
118    bsp_cleanup();
119  }
120
121  BSP_Configuration.work_space_start = work_space_start;
122
123  /*
124   *  Account for the console's resources
125   */
126
127  console_reserve_resources( &BSP_Configuration );
128
129  /*
130   *  initialize the CPU table for this BSP
131   */
132
133  Cpu_table.exceptions_in_RAM = TRUE;
134  Cpu_table.pretasking_hook   = bsp_pretasking_hook;    /* init libc, etc. */
135  Cpu_table.predriver_hook    = bsp_predriver_hook;
136  Cpu_table.postdriver_hook   = bsp_postdriver_hook;
137  Cpu_table.clicks_per_usec   = 66 / 4;  /* XXX get from linkcmds */
138
139  Cpu_table.do_zero_of_workspace = TRUE;
140  Cpu_table.interrupt_stack_size = (12 * 1024);
141}
Note: See TracBrowser for help on using the repository browser.