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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [powerpc/] [dmv177/] [startup/] [bspstart.c] - Blame information for rev 846

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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
 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994, 1997.
9
 *  On-Line Applications Research Corporation (OAR).
10
 *  All rights assigned to U.S. Government, 1994.
11
 *
12
 *  $Id: bspstart.c,v 1.2 2001-09-27 12:00:35 chris Exp $
13
 */
14
 
15
#include <bsp.h>
16
#include <rtems/libio.h>
17
 
18
#include <libcsupport.h>
19
 
20
#include <string.h>
21
 
22
/*
23
 *  The original table from the application and our copy of it with
24
 *  some changes.
25
 */
26
 
27
extern rtems_configuration_table  Configuration;
28
rtems_configuration_table         BSP_Configuration;
29
rtems_cpu_table                   Cpu_table;
30
rtems_unsigned32                  bsp_isr_level;
31
 
32
/*
33
 *  Use the shared implementations of the following routines
34
 */
35
 
36
void bsp_postdriver_hook(void);
37
void bsp_libc_init( void *, unsigned32, int );
38
 
39
/*PAGE
40
 *
41
 *  bsp_pretasking_hook
42
 *
43
 *  BSP pretasking hook.  Called just before drivers are initialized.
44
 *  Used to setup libc and install any BSP extensions.
45
 */
46
 
47
void bsp_pretasking_hook(void)
48
{
49
  extern int end;
50
  rtems_unsigned32 heap_start;
51
  rtems_unsigned32 heap_size;
52
 
53
  heap_start = (rtems_unsigned32) &end;
54
  if (heap_start & (CPU_ALIGNMENT-1))
55
    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
56
 
57
  heap_size = BSP_Configuration.work_space_start - (void *)&end;
58
  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
59
 
60
  bsp_libc_init((void *) heap_start, heap_size, 0);
61
 
62
#ifdef RTEMS_DEBUG
63
  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
64
#endif
65
}
66
 
67
/*  PAGE
68
 *
69
 *  bsp_predriver_hook
70
 *
71
 *  Initialization before drivers are setup.
72
 */
73
 
74
void bsp_predriver_hook(void)
75
{
76
  initialize_external_exception_vector();
77
}
78
 
79
/*PAGE
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
  unsigned int  msr_value = 0x2030;
90
 
91
  /*
92
   * Set BSP to initial value. Note: This value is a guess
93
   * check how the real board comes up. This is critical to
94
   * getting the source to work with the debugger.
95
   */
96
 
97
  _CPU_MSR_SET( msr_value );
98
 
99
  /*
100
   *  Need to "allocate" the memory for the RTEMS Workspace and
101
   *  tell the RTEMS configuration where it is.  This memory is
102
   *  not malloc'ed.  It is just "pulled from the air".
103
   */
104
 
105
  work_space_start =
106
    (unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
107
 
108
  if ( work_space_start <= (unsigned char *)&end ) {
109
    DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
110
    bsp_cleanup();
111
  }
112
 
113
  BSP_Configuration.work_space_start = work_space_start;
114
 
115
  /*
116
   *  initialize the CPU table for this BSP
117
   */
118
 
119
  Cpu_table.exceptions_in_RAM = TRUE;
120
  Cpu_table.pretasking_hook   = bsp_pretasking_hook;    /* init libc, etc. */
121
  Cpu_table.predriver_hook    = bsp_predriver_hook;
122
  Cpu_table.postdriver_hook   = bsp_postdriver_hook;
123
  /* Cpu_table.clicks_per_usec   = 66666667 / 4000000; */
124
  Cpu_table.clicks_per_usec   = 66666667 / 4000000 / 2;
125
 
126
  Cpu_table.do_zero_of_workspace = TRUE;
127
  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
128
 
129
  /*
130
   *  Enable whatever caching is desired
131
   */
132
 
133
#if ( PPC_USE_INSTRUCTION_CACHE )
134
  powerpc_instruction_cache_enable ();
135
#endif
136
 
137
#if ( PPC_USE_DATA_CACHE )
138
  powerpc_data_cache_enable ();
139
#endif
140
 
141
}

powered by: WebSVN 2.1.0

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