source: rtems/c/src/lib/libbsp/powerpc/psim/startup/bspstart.c @ 075d817

4.104.114.95
Last change on this file since 075d817 was f45169a, checked in by Joel Sherrill <joel.sherrill@…>, on 07/18/08 at 22:10:26

2008-07-18 Joel Sherrill <joel.sherrill@…>

  • startup/bspstart.c: This BSP is OK with SPRG0.
  • Property mode set to 100644
File size: 3.3 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-2008.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 *
14 *  $Id$
15 */
16
17#include <string.h>
18#include <fcntl.h>
19#include <bsp.h>
20#include <bsp/irq.h>
21#include <rtems/libio.h>
22#include <rtems/libcsupport.h>
23#include <rtems/bspIo.h>
24#include <rtems/powerpc/powerpc.h>
25
26#include <libcpu/cpuIdent.h>
27#include <libcpu/bat.h>
28#include <libcpu/spr.h>
29
30SPR_RW(SPRG1)
31
32/*  On psim, each click of the decrementer register corresponds
33 *  to 1 instruction.  By setting this to 100, we are indicating
34 *  that we are assuming it can execute 100 instructions per
35 *  microsecond.  This corresponds to sustaining 1 instruction
36 *  per cycle at 100 Mhz.  Whether this is a good guess or not
37 *  is anyone's guess.
38 */
39extern int PSIM_INSTRUCTIONS_PER_MICROSECOND;
40
41/*
42 * PCI Bus Frequency
43 */
44unsigned int BSP_bus_frequency;
45
46/*
47 * Time base divisior (how many tick for 1 second).
48 */
49unsigned int BSP_time_base_divisor;
50
51/*
52 * system init stack
53 */
54#define INIT_STACK_SIZE 0x1000
55
56void BSP_panic(char *s)
57{
58  printk("%s PANIC %s\n",_RTEMS_version, s);
59  __asm__ __volatile ("sc");
60}
61
62void _BSP_Fatal_error(unsigned int v)
63{
64  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
65  __asm__ __volatile ("sc");
66}
67
68/*
69 *  This method returns the base address and size of the area which
70 *  is to be allocated between the RTEMS Workspace and the C Program
71 *  Heap.
72 */
73void bsp_get_workarea(
74  void   **workarea_base,
75  size_t  *workarea_size,
76  size_t  *requested_heap_size
77)
78{
79  *workarea_base       = &end;
80  *workarea_size       = (void *)&RAM_END - (void *)&end;
81  *requested_heap_size = 0;
82}
83
84/*
85 *  bsp_start
86 *
87 *  This routine does the bulk of the system initialization.
88 */
89
90void bsp_start( void )
91{
92  extern unsigned long __rtems_end[];
93  uint32_t intrStackStart;
94  uint32_t intrStackSize;
95
96  /*
97   * Note we can not get CPU identification dynamically, so
98   * force current_ppc_cpu.
99   */
100  current_ppc_cpu = PPC_PSIM;
101
102  /*
103   *  initialize the device driver parameters
104   */
105  BSP_bus_frequency        = (unsigned int)&PSIM_INSTRUCTIONS_PER_MICROSECOND;
106  BSP_time_base_divisor    = 1;
107
108  /*
109   *  The simulator likes the exception table to be at 0xfff00000.
110   */
111
112  bsp_exceptions_in_RAM = FALSE;
113
114  /*
115   * Initialize the interrupt related settings.
116   */
117  intrStackStart = (uint32_t) __rtems_end + INIT_STACK_SIZE;
118  intrStackSize = rtems_configuration_get_interrupt_stack_size();
119
120  /*
121   * Initialize default raw exception handlers.
122   */
123  ppc_exc_initialize(
124    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
125    intrStackStart,
126    intrStackSize
127  );
128
129  /*
130   * Initalize RTEMS IRQ system
131   */
132  BSP_rtems_irq_mng_init(0);
133
134  /*
135   * Setup BATs and enable MMU
136   */
137  /* Memory */
138  setdbat(0, 0x0<<24, 0x0<<24, 1<<24, _PAGE_RW);
139  setibat(0, 0x0<<24, 0x0<<24, 1<<24,        0);
140  /* PCI    */
141  setdbat(1, 0x8<<24, 0x8<<24, 1<<24,  IO_PAGE);
142  setdbat(2, 0xc<<24, 0xc<<24, 1<<24,  IO_PAGE);
143
144  _write_MSR(_read_MSR() | MSR_DR | MSR_IR);
145  asm volatile("sync; isync");
146}
Note: See TracBrowser for help on using the repository browser.