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

4.115
Last change on this file since 183af89 was c988f180, checked in by Sebastian Huber <sebastian.huber@…>, on 04/02/12 at 09:59:36

bsp/gen83xx: Fix console driver configuration

  • Property mode set to 100644
File size: 3.7 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 parameter for clock driver */
38uint32_t bsp_time_base_frequency;
39
40/* Legacy */
41uint32_t bsp_clicks_per_usec;
42
43/* Default decrementer exception handler */
44static int mpc83xx_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number)
45{
46  ppc_set_decrementer_register(UINT32_MAX);
47
48  return 0;
49}
50
51void BSP_panic(char *s)
52{
53  rtems_interrupt_level level;
54
55  rtems_interrupt_disable(level);
56
57  printk("%s PANIC %s\n", rtems_get_version_string(), s);
58
59  while (1) {
60    /* Do nothing */
61  }
62}
63
64void _BSP_Fatal_error(unsigned n)
65{
66  rtems_interrupt_level level;
67
68  rtems_interrupt_disable( level);
69
70  printk( "%s PANIC ERROR %u\n", rtems_get_version_string(), n);
71
72  while (1) {
73    /* Do nothing */
74  }
75}
76
77void bsp_start( void)
78{
79  rtems_status_code sc = RTEMS_SUCCESSFUL;
80  unsigned long i = 0;
81
82  ppc_cpu_id_t myCpu;
83  ppc_cpu_revision_t myCpuRevision;
84
85  uintptr_t interrupt_stack_start = (uintptr_t) bsp_interrupt_stack_start;
86  uintptr_t interrupt_stack_size = (uintptr_t) bsp_interrupt_stack_size;
87
88  /*
89   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
90   * store the result in global variables so that it can be used latter...
91   */
92  myCpu = get_ppc_cpu_type();
93  myCpuRevision = get_ppc_cpu_revision();
94
95  /* Basic CPU initialization */
96  cpu_init();
97
98  /*
99   * Enable instruction and data caches. Do not force writethrough mode.
100   */
101
102#ifdef BSP_INSTRUCTION_CACHE_ENABLED
103  rtems_cache_enable_instruction();
104#endif
105
106#ifdef BSP_DATA_CACHE_ENABLED
107  rtems_cache_enable_data();
108#endif
109
110  /*
111   * This is evaluated during runtime, so it should be ok to set it
112   * before we initialize the drivers.
113   */
114
115  /* Initialize some device driver parameters */
116
117#ifdef HAS_UBOOT
118  BSP_bus_frequency = bsp_uboot_board_info.bi_busfreq;
119#else /* HAS_UBOOT */
120  BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
121#endif /* HAS_UBOOT */
122  bsp_time_base_frequency = BSP_bus_frequency / 4;
123  bsp_clicks_per_usec = bsp_time_base_frequency / 1000000;
124
125  /* Initialize some console parameters */
126  for (i = 0; i < Console_Configuration_Count; ++i) {
127    Console_Configuration_Ports [i].ulClock = BSP_bus_frequency;
128
129    #ifdef HAS_UBOOT
130      Console_Configuration_Ports [i].pDeviceParams =
131        (void *) bsp_uboot_board_info.bi_baudrate;
132    #endif
133  }
134
135  /* Initialize exception handler */
136#ifndef BSP_DATA_CACHE_ENABLED
137  ppc_exc_cache_wb_check = 0;
138#endif
139  sc = ppc_exc_initialize(
140    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
141    interrupt_stack_start,
142    interrupt_stack_size
143  );
144  if (sc != RTEMS_SUCCESSFUL) {
145    BSP_panic("cannot initialize exceptions");
146  }
147
148  /* Install default handler for the decrementer exception */
149  sc = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler);
150  if (sc != RTEMS_SUCCESSFUL) {
151    BSP_panic("cannot install decrementer exception handler");
152  }
153
154  /* Initalize interrupt support */
155  sc = bsp_interrupt_initialize();
156  if (sc != RTEMS_SUCCESSFUL) {
157    BSP_panic("cannot intitialize interrupts\n");
158  }
159
160#ifdef SHOW_MORE_INIT_SETTINGS
161  printk("Exit from bspstart\n");
162#endif
163}
Note: See TracBrowser for help on using the repository browser.