source: rtems/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c @ 760ef104

4.115
Last change on this file since 760ef104 was ce0922e, checked in by Sebastian Huber <sebastian.huber@…>, on 12/30/10 at 13:16:41

2010-12-30 Sebastian Huber <sebastian.huber@…>

  • include/u-boot.h: Removed file.
  • include/u-boot-config.h, include/tsec-config.h: New files.
  • include/bsp.h, start/start.S, startup/bspstart.c: Use new U-Boot support.
  • network/network.c: Update for API changes.
  • Makefile.am, preinstall.am: Reflect changes above.
  • 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 <libchip/serial.h>
24
25#include <libcpu/powerpc-utility.h>
26
27#include <bsp.h>
28#include <bsp/vectors.h>
29#include <bsp/bootcard.h>
30#include <bsp/irq-generic.h>
31#include <bsp/u-boot.h>
32
33/* Configuration parameters for console driver, ... */
34unsigned int BSP_bus_frequency;
35
36/* Configuration parameters for clock driver, ... */
37uint32_t bsp_clicks_per_usec;
38
39/* Default decrementer exception handler */
40static int mpc83xx_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number)
41{
42  ppc_set_decrementer_register(UINT32_MAX);
43
44  return 0;
45}
46
47void BSP_panic(char *s)
48{
49  rtems_interrupt_level level;
50
51  rtems_interrupt_disable(level);
52
53  printk("%s PANIC %s\n", rtems_get_version_string(), s);
54
55  while (1) {
56    /* Do nothing */
57  }
58}
59
60void _BSP_Fatal_error(unsigned n)
61{
62  rtems_interrupt_level level;
63
64  rtems_interrupt_disable( level);
65
66  printk( "%s PANIC ERROR %u\n", rtems_get_version_string(), n);
67
68  while (1) {
69    /* Do nothing */
70  }
71}
72
73void bsp_start( void)
74{
75  rtems_status_code sc = RTEMS_SUCCESSFUL;
76  unsigned long i = 0;
77
78  ppc_cpu_id_t myCpu;
79  ppc_cpu_revision_t myCpuRevision;
80
81  uintptr_t interrupt_stack_start = (uintptr_t) bsp_interrupt_stack_start;
82  uintptr_t interrupt_stack_size = (uintptr_t) bsp_interrupt_stack_size;
83
84  /*
85   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
86   * store the result in global variables so that it can be used latter...
87   */
88  myCpu = get_ppc_cpu_type();
89  myCpuRevision = get_ppc_cpu_revision();
90
91  /* Basic CPU initialization */
92  cpu_init();
93
94  /*
95   * Enable instruction and data caches. Do not force writethrough mode.
96   */
97
98#if INSTRUCTION_CACHE_ENABLE
99  rtems_cache_enable_instruction();
100#endif
101
102#if DATA_CACHE_ENABLE
103  rtems_cache_enable_data();
104#endif
105
106  /*
107   * This is evaluated during runtime, so it should be ok to set it
108   * before we initialize the drivers.
109   */
110
111  /* Initialize some device driver parameters */
112
113#ifdef HAS_UBOOT
114  BSP_bus_frequency = bsp_uboot_board_info.bi_busfreq;
115  bsp_clicks_per_usec = bsp_uboot_board_info.bi_busfreq / 4000000;
116#else /* HAS_UBOOT */
117  BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
118  bsp_clicks_per_usec = BSP_bus_frequency / 4000000;
119#endif /* HAS_UBOOT */
120
121  /* Initialize some console parameters */
122  for (i = 0; i < Console_Port_Count; ++i) {
123    Console_Port_Tbl [i].ulClock = BSP_bus_frequency;
124
125    #ifdef HAS_UBOOT
126      Console_Port_Tbl [i].pDeviceParams =
127        (void *) bsp_uboot_board_info.bi_baudrate;
128    #endif
129  }
130
131  /* Initialize exception handler */
132  sc = ppc_exc_initialize(
133    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
134    interrupt_stack_start,
135    interrupt_stack_size
136  );
137  if (sc != RTEMS_SUCCESSFUL) {
138    BSP_panic("cannot initialize exceptions");
139  }
140
141  /* Install default handler for the decrementer exception */
142  sc = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler);
143  if (sc != RTEMS_SUCCESSFUL) {
144    BSP_panic("cannot install decrementer exception handler");
145  }
146
147  /* Initalize interrupt support */
148  sc = bsp_interrupt_initialize();
149  if (sc != RTEMS_SUCCESSFUL) {
150    BSP_panic("cannot intitialize interrupts\n");
151  }
152
153#ifdef SHOW_MORE_INIT_SETTINGS
154  printk("Exit from bspstart\n");
155#endif
156}
Note: See TracBrowser for help on using the repository browser.