source: rtems/bsps/powerpc/psim/start/bspstart.c @ fad3f79b

5
Last change on this file since fad3f79b was fad3f79b, checked in by Sebastian Huber <sebastian.huber@…>, on 08/31/18 at 05:44:53

bsps: BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN

Remove the BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN hack. The interrupt
stacks are now allocated by the linker.

Update #3459.

  • Property mode set to 100644
File size: 2.7 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.org/license/LICENSE.
13 */
14
15#include <string.h>
16#include <fcntl.h>
17#include <bsp.h>
18#include <bsp/irq.h>
19#include <psim.h>
20#include <bsp/bootcard.h>
21#include <bsp/linker-symbols.h>
22#include <rtems/bspIo.h>
23#include <rtems/counter.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 *  Driver configuration parameters
48 */
49uint32_t   bsp_clicks_per_usec;
50
51/*
52 * Memory on this board.
53 */
54uint32_t BSP_mem_size = (uint32_t)RamSize;
55
56/*
57 * Time base divisior (how many tick for 1 second).
58 */
59unsigned int BSP_time_base_divisor;
60
61extern unsigned long __rtems_end[];
62
63uint32_t _CPU_Counter_frequency(void)
64{
65  return bsp_clicks_per_usec * 1000000;
66}
67
68/*
69 *  bsp_start
70 *
71 *  This routine does the bulk of the system initialization.
72 */
73void bsp_start( void )
74{
75  /*
76   * Note we can not get CPU identification dynamically.
77   * PVR has to be set to PPC_PSIM (0xfffe) from the device
78   * file.
79   */
80
81  get_ppc_cpu_type();
82
83  /*
84   *  initialize the device driver parameters
85   */
86  BSP_bus_frequency        = (unsigned int)PSIM_INSTRUCTIONS_PER_MICROSECOND;
87  bsp_clicks_per_usec      = BSP_bus_frequency;
88  BSP_time_base_divisor    = 1;
89
90  /*
91   * Initialize default raw exception handlers.
92   */
93  ppc_exc_initialize_with_vector_base(
94    (uintptr_t) _Configuration_Interrupt_stack_area_begin,
95    rtems_configuration_get_interrupt_stack_size(),
96    (void *) 0xfff00000
97  );
98
99  /*
100   * Initalize RTEMS IRQ system
101   */
102  BSP_rtems_irq_mng_init(0);
103
104  /*
105   * Setup BATs and enable MMU
106   */
107  /* Memory */
108  setdbat(0, 0x0<<24, 0x0<<24, 2<<24, _PAGE_RW);
109  setibat(0, 0x0<<24, 0x0<<24, 2<<24,        0);
110  /* PCI    */
111  setdbat(1, 0x8<<24, 0x8<<24, 1<<24,  IO_PAGE);
112  setdbat(2, 0xc<<24, 0xc<<24, 1<<24,  IO_PAGE);
113
114  _write_MSR(_read_MSR() | MSR_DR | MSR_IR);
115  __asm__ volatile("sync; isync");
116
117}
Note: See TracBrowser for help on using the repository browser.