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

4.11
Last change on this file since b1e8a58 was b1e8a58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 14, 2012 at 8:57:55 AM

bsps/powerpc: Exception initialization error is fatal

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