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

Subversion Repositories openrisc

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

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-1997.
9
 *  On-Line Applications Research Corporation (OAR).
10
 *  Copyright assigned to U.S. Government, 1994.
11
 *
12
 *  The license and distribution terms for this file may in
13
 *  the file LICENSE in this distribution or at
14
 *  http://www.OARcorp.com/rtems/license.html.
15
 *
16
 *  $Id:
17
 */
18
 
19
#include <bsp.h>
20
#include <rtems/libio.h>
21
 
22
#include <libcsupport.h>
23
 
24
#include <string.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
rtems_cpu_table                   Cpu_table;
34
rtems_unsigned32                  bsp_isr_level;
35
 
36
/*
37
 *  Use the shared implementations of the following routines
38
 */
39
 
40
void bsp_postdriver_hook(void);
41
void bsp_libc_init( void *, unsigned32, int );
42
 
43
/*PAGE
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
 
51
void bsp_pretasking_hook(void)
52
{
53
  extern int end;
54
  rtems_unsigned32 heap_start;
55
  rtems_unsigned32 heap_size;
56
 
57
  heap_start = (rtems_unsigned32) &end;
58
  if (heap_start & (CPU_ALIGNMENT-1))
59
    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
60
 
61
  heap_size = BSP_Configuration.work_space_start - (void *)&end;
62
  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
63
 
64
  bsp_libc_init((void *) heap_start, heap_size, 0);
65
 
66
#ifdef RTEMS_DEBUG
67
  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
68
#endif
69
}
70
 
71
/*PAGE
72
 *
73
 *  bsp_predriver_hook
74
 *
75
 *  Before drivers are setup initialize interupt vectors.
76
 */
77
 
78
void init_RTC();
79
void initialize_PMC();
80
 
81
void bsp_predriver_hook(void)
82
{
83
  init_RTC();
84
 
85
  init_PCI();
86
  initialize_universe();
87
  initialize_PCI_bridge ();
88
 
89
#if (HAS_PMC_PSC8)
90
  initialize_PMC();
91
#endif
92
 
93
 /*
94
  * Initialize Bsp General purpose vector table.
95
  */
96
 initialize_external_exception_vector();
97
 
98
#if (0)
99
  /*
100
   * XXX - Modify this to write a 48000000 (loop to self) command
101
   *       to each interrupt location.  This is better for debug.
102
   */
103
 bsp_spurious_initialize();
104
#endif
105
 
106
}
107
 
108
/*PAGE
109
 *
110
 *  initialize_PMC
111
 */
112
 
113
void initialize_PMC() {
114
  volatile rtems_unsigned32 *PMC_addr;
115
  rtems_unsigned8  data;
116
 
117
#if (0) /* First Values sent */
118
  /*
119
   * set PMC base address.
120
   */
121
  PMC_addr  = SCORE603E_PCI_DEVICE_ADDRESS( 0x14 );
122
  *PMC_addr = (SCORE603E_PCI_REGISTER_BASE >> 24) & 0x3f;
123
 
124
  /*
125
   * Clear status, enable SERR and memory space only.
126
   */
127
  PMC_addr = SCORE603E_PCI_DEVICE_ADDRESS( 0x4 );
128
  *PMC_addr = 0x0201ff37;
129
 
130
  /*
131
   * Bit 0 and 1 HI cause Medium Loopback to occur.
132
   */
133
  PMC_addr = (volatile rtems_unsigned32 *)
134
        SCORE603E_PMC_SERIAL_ADDRESS( 0x100000 );
135
  data = *PMC_addr;
136
  /*   *PMC_addr = data | 0x3;  */
137
  *PMC_addr = data & 0xfc;
138
 
139
#endif
140
 
141
 
142
#if (1)
143
 
144
  /*
145
   * Clear status, enable SERR and memory space only.
146
   */
147
  PMC_addr = SCORE603E_PCI_DEVICE_ADDRESS( 0x4 );
148
  *PMC_addr = 0x020080cc;
149
 
150
  /*
151
   * set PMC base address.
152
   */
153
  PMC_addr  = SCORE603E_PCI_DEVICE_ADDRESS( 0x14 );
154
  *PMC_addr = (SCORE603E_PCI_REGISTER_BASE >> 24) & 0x3f;
155
 
156
  PMC_addr = (volatile rtems_unsigned32 *)
157
      SCORE603E_PMC_SERIAL_ADDRESS( 0x100000 );
158
  data = *PMC_addr;
159
  *PMC_addr = data & 0xfc;
160
 
161
#endif
162
}
163
 
164
 
165
 
166
/*PAGE
167
 *
168
 *  SCORE603e_bsp_postdriver_hook
169
 *
170
 *  Standard post driver hook plus some BSP specific stuff.
171
 */
172
 
173
void SCORE603e_bsp_postdriver_hook(void)
174
{
175
  extern void Init_EE_mask_init(void);
176
 
177
  bsp_postdriver_hook();
178
 
179
  Init_EE_mask_init();
180
}
181
 
182
void bsp_set_trap_vectors( void );
183
 
184
/*PAGE
185
 *
186
 *  bsp_start
187
 *
188
 *  This routine does the bulk of the system initialization.
189
 */
190
 
191
void bsp_start( void )
192
{
193
  unsigned char *work_space_start;
194
  unsigned int  msr_value = 0x0000;
195
  volatile rtems_unsigned32 *ptr;
196
 
197
  delay( 1000 );
198
 
199
  /*
200
   *  Zero out lots of memory
201
   */
202
 
203
  memset(
204
    &end,
205
    0,
206
    (unsigned char *)&RAM_END - (unsigned char *) &end
207
  );
208
 
209
  /*
210
   *  There are multiple ROM monitors available for this board.
211
   */
212
#if (SCORE603E_USE_SDS)
213
 
214
  /*
215
   * Write instruction for Unconditional Branch to ROM vector.
216
   */
217
 
218
   Code = 0x4bf00002;
219
   for (Address = 0x100; Address <= 0xe00; Address += 0x100) {
220
     A_Vector = (unsigned32    *)Address;
221
     Code = 0x4bf00002 + Address;
222
     *A_Vector = Code;
223
   }
224
 
225
   for (Address = 0x1000; Address <= 0x1400; Address += 0x100) {
226
     A_Vector = (unsigned32    *)Address;
227
     Code = 0x4bf00002 + Address;
228
     *A_Vector = Code;
229
   }
230
 
231
  Cpu_table.exceptions_in_RAM = TRUE;
232
  msr_value = 0x2030;
233
 
234
#elif (SCORE603E_USE_OPEN_FIRMWARE)
235
  Cpu_table.exceptions_in_RAM = TRUE;
236
  msr_value = 0x2030;
237
 
238
#elif (SCORE603E_USE_NONE)
239
  Cpu_table.exceptions_in_RAM = TRUE;
240
  msr_value = 0x2030;
241
  _CPU_MSR_SET( msr_value );
242
  bsp_set_trap_vectors();
243
 
244
#elif (SCORE603E_USE_DINK)
245
  Cpu_table.exceptions_in_RAM = TRUE;
246
  msr_value = 0x2030;
247
  _CPU_MSR_SET( msr_value );
248
 
249
  /*
250
   * Override the DINK error on a Decrementor interrupt.
251
   */
252
  /* org    dec_vector  - rfi */
253
  ptr = (rtems_unsigned32 *)0x900;
254
  *ptr = 0x4c000064;
255
 
256
#else
257
#error "SCORE603E BSPSTART.C -- what ROM monitor are you using"
258
#endif
259
 
260
  _CPU_MSR_SET( msr_value );
261
 
262
  /*
263
   *  Need to "allocate" the memory for the RTEMS Workspace and
264
   *  tell the RTEMS configuration where it is.  This memory is
265
   *  not malloc'ed.  It is just "pulled from the air".
266
   */
267
 
268
  work_space_start =
269
    (unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
270
 
271
  if ( work_space_start <= (unsigned char *)&end ) {
272
    DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
273
    bsp_cleanup();
274
  }
275
 
276
  BSP_Configuration.work_space_start = work_space_start;
277
 
278
  /*
279
   *  initialize the CPU table for this BSP
280
   */
281
 
282
  /* Cpu_table.exceptions_in_RAM was set above */
283
  Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */
284
  Cpu_table.predriver_hook  = bsp_predriver_hook;   /* Init vectors    */
285
  Cpu_table.postdriver_hook = SCORE603e_bsp_postdriver_hook;
286
  Cpu_table.clicks_per_usec = 66 / 4;  /* XXX get from linkcmds */
287
  Cpu_table.do_zero_of_workspace = TRUE;
288
  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
289
  Cpu_table.idle_task_stack_size = (3 * STACK_MINIMUM_SIZE);
290
 
291
#if ( PPC_USE_DATA_CACHE )
292
  instruction_cache_enable ();
293
  data_cache_enable ();
294
#endif
295
}
296
 

powered by: WebSVN 2.1.0

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