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

4.11
Last change on this file since e570c313 was e570c313, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 24, 2011 at 3:32:04 PM

2011-01-24 Joel Sherrill <joel.sherrill@…>

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