source: rtems/c/src/lib/libbsp/powerpc/qemuppc/startup/bspstart.c @ 2e5cf7f

5
Last change on this file since 2e5cf7f was 2e5cf7f, checked in by Sebastian Huber <sebastian.huber@…>, on 03/16/18 at 14:09:36

bsps/powerpc: Use shared linker command file

Close #3339.

  • Property mode set to 100644
File size: 3.0 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
18#include <rtems/counter.h>
19
20#include <libcpu/bat.h>
21#include <libcpu/spr.h>
22#include <libcpu/powerpc-utility.h>
23
24#include <bsp.h>
25#include <bsp/irq.h>
26#include <bsp/vectors.h>
27#include <bsp/bootcard.h>
28#include <bsp/irq-generic.h>
29
30/*
31 * CPU Bus Frequency
32 */
33unsigned int BSP_bus_frequency;
34
35/* Configuration parameter for clock driver */
36uint32_t bsp_time_base_frequency;
37
38/* Legacy */
39uint32_t bsp_clicks_per_usec;
40
41/*
42 * Memory on this board.
43 */
44extern char RamSize[];
45extern char bsp_interrupt_stack_start[];
46extern char bsp_interrupt_stack_end[];
47uint32_t BSP_mem_size = (uint32_t)RamSize;
48
49/* Default decrementer exception handler */
50static int default_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number)
51{
52  ppc_set_decrementer_register(UINT32_MAX);
53
54  return 0;
55}
56
57/*
58 *  bsp_start
59 *
60 *  This routine does the bulk of the system initialization.
61 */
62
63void bsp_start( void )
64{
65  rtems_status_code sc = RTEMS_SUCCESSFUL;
66  uintptr_t intrStackStart;
67  uintptr_t intrStackSize;
68
69  /*
70   * Note we can not get CPU identification dynamically, so
71   * force current_ppc_cpu.
72   */
73  current_ppc_cpu = PPC_PSIM;
74
75  /*
76   *  initialize the device driver parameters
77   * assume we are running with 20MHz bus
78   * this should speed up some tests :-)
79   */
80  BSP_bus_frequency        = 20;
81  bsp_time_base_frequency  = 20000000;
82  bsp_clicks_per_usec      = BSP_bus_frequency;
83  rtems_counter_initialize_converter(bsp_time_base_frequency);
84
85  /*
86   * Initialize the interrupt related settings.
87   */
88  intrStackStart = (uintptr_t) bsp_interrupt_stack_start;
89  intrStackSize =  (uintptr_t) bsp_interrupt_stack_end - intrStackStart;
90
91  BSP_mem_size = (uint32_t )RamSize;
92
93  /*
94   * Initialize default raw exception handlers.
95   */
96  ppc_exc_initialize(intrStackStart, intrStackSize);
97
98  /* Install default handler for the decrementer exception */
99  sc = ppc_exc_set_handler( ASM_DEC_VECTOR, default_decrementer_exception_handler);
100  if (sc != RTEMS_SUCCESSFUL) {
101    rtems_panic("cannot install decrementer exception handler");
102  }
103
104  /* Initalize interrupt support */
105  bsp_interrupt_initialize();
106
107#if 0
108  /*
109   * Setup BATs and enable MMU
110   */
111  /* Memory */
112  setdbat(0, 0x0<<24, 0x0<<24, 2<<24, _PAGE_RW);
113  setibat(0, 0x0<<24, 0x0<<24, 2<<24,        0);
114  /* PCI    */
115  setdbat(1, 0x8<<24, 0x8<<24, 1<<24,  IO_PAGE);
116  setdbat(2, 0xc<<24, 0xc<<24, 1<<24,  IO_PAGE);
117
118  _write_MSR(_read_MSR() | MSR_DR | MSR_IR);
119  __asm__ volatile("sync; isync");
120#endif
121}
Note: See TracBrowser for help on using the repository browser.