source: rtems/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c @ 2d2de4eb

4.104.115
Last change on this file since 2d2de4eb was 2d2de4eb, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 10/23/09 at 07:32:46

Update for exception support changes.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc83xx
5 *
6 * @brief Source for BSP startup code.
7 */
8
9/*
10 * Copyright (c) 2008
11 * Embedded Brains GmbH
12 * Obere Lagerstr. 30
13 * D-82178 Puchheim
14 * Germany
15 * rtems@embedded-brains.de
16 *
17 * The license and distribution terms for this file may be found in the file
18 * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
19 *
20 * $Id$
21 */
22
23#include <libcpu/powerpc-utility.h>
24
25#include <bsp.h>
26#include <bsp/vectors.h>
27#include <bsp/bootcard.h>
28#include <bsp/irq-generic.h>
29
30#ifdef HAS_UBOOT
31
32/*
33 * We want this in the data section, because the startup code clears the BSS
34 * section after the initialization of the board info.
35 */
36bd_t bsp_uboot_board_info = { .bi_baudrate = 123 };
37
38/* Size in words */
39const size_t bsp_uboot_board_info_size = (sizeof( bd_t) + 3) / 4;
40
41#endif /* HAS_UBOOT */
42
43/* Configuration parameters for console driver, ... */
44unsigned int BSP_bus_frequency;
45
46/* Configuration parameters for clock driver, ... */
47uint32_t bsp_clicks_per_usec;
48
49/* Default decrementer exception handler */
50static int mpc83xx_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number)
51{
52  ppc_set_decrementer_register(UINT32_MAX);
53
54  return 0;
55}
56
57void BSP_panic(char *s)
58{
59  rtems_interrupt_level level;
60
61  rtems_interrupt_disable(level);
62
63  printk("%s PANIC %s\n", rtems_get_version_string(), s);
64
65  while (1) {
66    /* Do nothing */
67  }
68}
69
70void _BSP_Fatal_error(unsigned n)
71{
72  rtems_interrupt_level level;
73
74  rtems_interrupt_disable( level);
75
76  printk( "%s PANIC ERROR %u\n", rtems_get_version_string(), n);
77
78  while (1) {
79    /* Do nothing */
80  }
81}
82
83void bsp_start( void)
84{
85  rtems_status_code sc = RTEMS_SUCCESSFUL;
86
87  ppc_cpu_id_t myCpu;
88  ppc_cpu_revision_t myCpuRevision;
89
90  uintptr_t interrupt_stack_start = (uintptr_t) bsp_interrupt_stack_start;
91  uintptr_t interrupt_stack_size = (uintptr_t) bsp_interrupt_stack_size;
92
93  /*
94   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
95   * store the result in global variables so that it can be used latter...
96   */
97  myCpu = get_ppc_cpu_type();
98  myCpuRevision = get_ppc_cpu_revision();
99
100  /* Basic CPU initialization */
101  cpu_init();
102
103  /*
104   * Enable instruction and data caches. Do not force writethrough mode.
105   */
106
107#if INSTRUCTION_CACHE_ENABLE
108  rtems_cache_enable_instruction();
109#endif
110
111#if DATA_CACHE_ENABLE
112  rtems_cache_enable_data();
113#endif
114
115  /*
116   * This is evaluated during runtime, so it should be ok to set it
117   * before we initialize the drivers.
118   */
119
120  /* Initialize some device driver parameters */
121
122#ifdef HAS_UBOOT
123  BSP_bus_frequency = bsp_uboot_board_info.bi_busfreq;
124  bsp_clicks_per_usec = bsp_uboot_board_info.bi_busfreq / 4000000;
125#else /* HAS_UBOOT */
126  BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
127  bsp_clicks_per_usec = BSP_bus_frequency / 4000000;
128#endif /* HAS_UBOOT */
129
130  /* Initialize exception handler */
131  sc = ppc_exc_initialize(
132    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
133    interrupt_stack_start,
134    interrupt_stack_size
135  );
136  if (sc != RTEMS_SUCCESSFUL) {
137    BSP_panic("cannot initialize exceptions");
138  }
139
140  /* Install default handler for the decrementer exception */
141  sc = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler);
142  if (sc != RTEMS_SUCCESSFUL) {
143    BSP_panic("cannot install decrementer exception handler");
144  }
145
146  /* Initalize interrupt support */
147  sc = bsp_interrupt_initialize();
148  if (sc != RTEMS_SUCCESSFUL) {
149    BSP_panic("cannot intitialize interrupts\n");
150  }
151
152#ifdef SHOW_MORE_INIT_SETTINGS
153  printk("Exit from bspstart\n");
154#endif
155}
Note: See TracBrowser for help on using the repository browser.