OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [powerpc/] [psim/] [startup/] [bspstart.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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-1999.
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
 *  bspstart.c,v 1.13 2002/04/18 20:55:04 joel Exp
16
 */
17
 
18
#include <string.h>
19
#include <fcntl.h>
20
 
21
#include <bsp.h>
22
#include <rtems/libio.h>
23
#include <rtems/libcsupport.h>
24
#include <rtems/bspIo.h>
25
 
26
/*
27
 *  The original table from the application and our copy of it with
28
 *  some changes.
29
 */
30
 
31
extern rtems_configuration_table  Configuration;
32
rtems_configuration_table         BSP_Configuration;
33
 
34
rtems_cpu_table   Cpu_table;
35
rtems_unsigned32  bsp_isr_level;
36
 
37
/*
38
 *  Tells us where to put the workspace in case remote debugger is present.
39
 */
40
 
41
#if 0
42
extern rtems_unsigned32  rdb_start;
43
#endif
44
 
45
/*
46
 *  Use the shared implementations of the following routines
47
 */
48
 
49
void bsp_postdriver_hook(void);
50
void bsp_libc_init( void *, unsigned32, int );
51
 
52
/*
53
 *  bsp_pretasking_hook
54
 *
55
 *  BSP pretasking hook.  Called just before drivers are initialized.
56
 *  Used to setup libc and install any BSP extensions.
57
 */
58
 
59
void bsp_pretasking_hook(void)
60
{
61
  extern int end;
62
  rtems_unsigned32 heap_start;
63
  rtems_unsigned32 heap_size;
64
 
65
  heap_start = (rtems_unsigned32) &end;
66
  if (heap_start & (CPU_ALIGNMENT-1))
67
    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
68
 
69
  heap_size = BSP_Configuration.work_space_start - (void *)&end;
70
  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
71
 
72
  bsp_libc_init((void *) heap_start, heap_size, 0);
73
 
74
#ifdef RTEMS_DEBUG
75
  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
76
#endif
77
 
78
}
79
 
80
/*
81
 *  bsp_start
82
 *
83
 *  This routine does the bulk of the system initialization.
84
 */
85
 
86
void bsp_start( void )
87
{
88
  unsigned char *work_space_start;
89
 
90
#if 0
91
  /*
92
   * Set MSR to show vectors at 0 XXX
93
   */
94
  _CPU_MSR_Value( msr_value );
95
  msr_value &= ~PPC_MSR_EP;
96
  _CPU_MSR_SET( msr_value );
97
#endif
98
 
99
  /*
100
   * Set up our hooks
101
   * Make sure libc_init is done before drivers initialized so that
102
   * they can use atexit()
103
   */
104
 
105
  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
106
  Cpu_table.postdriver_hook = bsp_postdriver_hook;
107
 
108
  /*
109
   *  Is this true?
110
   *
111
   *  PSIM does zero out memory BUT only when IT begins execution.  Thus
112
   *  if we want to have a clean slate in the workspace each time we
113
   *  begin execution of OUR application, then we must zero the workspace.
114
   *
115
   *  It is true that it takes simulated time to clear the memory.
116
   */
117
 
118
  Cpu_table.do_zero_of_workspace = FALSE;
119
 
120
  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
121
 
122
  /*
123
   *  The monitor likes the exception table to be at 0x0.
124
   */
125
 
126
  Cpu_table.exceptions_in_RAM = TRUE;
127
 
128
  BSP_Configuration.work_space_size += 1024;
129
 
130
  work_space_start =
131
    (unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
132
 
133
  if ( work_space_start <= (unsigned char *)&end ) {
134
    printk( "bspstart: Not enough RAM!!!\n" );
135
    bsp_cleanup();
136
  }
137
 
138
  BSP_Configuration.work_space_start = work_space_start;
139
 
140
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.