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

5
Last change on this file since 097ea1e was 097ea1e, checked in by Joel Sherrill <joel@…>, on 03/05/20 at 23:51:12

psim: Rework device tree so devices do not conflict with 256MB RAM

updates #3849.

  • Property mode set to 100644
File size: 2.6 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  ppc_exc_initialize_with_vector_base(
91    (uintptr_t) _ISR_Stack_area_begin,
92    (void *) 0xfff00000
93  );
94
95  /*
96   * Initalize RTEMS IRQ system
97   */
98  BSP_rtems_irq_mng_init(0);
99
100  /*
101   * Setup BATs and enable MMU
102   */
103  /* Memory */
104  setdbat(0, 0x0<<28, 0x0<<28, 1<<28, _PAGE_RW);
105  setibat(0, 0x0<<28, 0x0<<28, 1<<28,        0);
106  /* PCI    */
107  setdbat(1, 0x08<<24, 0x08<<24, 1<<24,  IO_PAGE);
108  setdbat(2, 0xfc<<24, 0xfc<<24, 1<<24,  IO_PAGE);
109
110  _write_MSR(_read_MSR() | MSR_DR | MSR_IR);
111  __asm__ volatile("sync; isync");
112
113}
Note: See TracBrowser for help on using the repository browser.