source: rtems/bsps/powerpc/gen83xx/start/bspstart.c @ 8f8ccee

5
Last change on this file since 8f8ccee was 9964895, checked in by Sebastian Huber <sebastian.huber@…>, on 04/20/18 at 08:35:35

bsps: Move startup files to bsps

Adjust build support files to new directory layout.

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc83xx
5 *
6 * @brief Source for BSP startup code.
7 */
8
9/*
10 * Copyright (c) 2008-2014 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <info@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#include <rtems/counter.h>
24
25#include <libchip/ns16550.h>
26
27#include <libcpu/powerpc-utility.h>
28
29#include <bsp.h>
30#include <bsp/vectors.h>
31#include <bsp/bootcard.h>
32#include <bsp/irq-generic.h>
33#include <bsp/linker-symbols.h>
34#include <bsp/u-boot.h>
35#include <bsp/console-termios.h>
36
37/* Configuration parameters for console driver, ... */
38unsigned int BSP_bus_frequency;
39
40/* Configuration parameter for clock driver */
41uint32_t bsp_time_base_frequency;
42
43/* Legacy */
44uint32_t bsp_clicks_per_usec;
45
46/* Default decrementer exception handler */
47static int mpc83xx_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number)
48{
49  ppc_set_decrementer_register(UINT32_MAX);
50
51  return 0;
52}
53
54void bsp_start( void)
55{
56  rtems_status_code sc = RTEMS_SUCCESSFUL;
57  unsigned long i = 0;
58
59  /*
60   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
61   * store the result in global variables so that it can be used latter...
62   */
63  get_ppc_cpu_type();
64  get_ppc_cpu_revision();
65
66  /* Basic CPU initialization */
67  cpu_init();
68
69  /*
70   * Enable instruction and data caches. Do not force writethrough mode.
71   */
72
73#ifdef BSP_INSTRUCTION_CACHE_ENABLED
74  rtems_cache_enable_instruction();
75#endif
76
77#ifdef BSP_DATA_CACHE_ENABLED
78  rtems_cache_enable_data();
79#endif
80
81  /*
82   * This is evaluated during runtime, so it should be ok to set it
83   * before we initialize the drivers.
84   */
85
86  /* Initialize some device driver parameters */
87
88#ifdef HAS_UBOOT
89  BSP_bus_frequency = bsp_uboot_board_info.bi_busfreq;
90#else /* HAS_UBOOT */
91  BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
92#endif /* HAS_UBOOT */
93  bsp_time_base_frequency = BSP_bus_frequency / 4;
94  bsp_clicks_per_usec = bsp_time_base_frequency / 1000000;
95  rtems_counter_initialize_converter(bsp_time_base_frequency);
96
97  /* Initialize some console parameters */
98  for (i = 0; i < console_device_count; ++i) {
99    ns16550_context *ctx = (ns16550_context *) console_device_table[i].context;
100
101    ctx->clock = BSP_bus_frequency;
102
103    #ifdef HAS_UBOOT
104      ctx->initial_baud = bsp_uboot_board_info.bi_baudrate;
105    #endif
106  }
107
108  /* Initialize exception handler */
109#ifndef BSP_DATA_CACHE_ENABLED
110  ppc_exc_cache_wb_check = 0;
111#endif
112  ppc_exc_initialize(
113    (uintptr_t) bsp_section_work_begin,
114    rtems_configuration_get_interrupt_stack_size()
115  );
116
117  /* Install default handler for the decrementer exception */
118  sc = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler);
119  if (sc != RTEMS_SUCCESSFUL) {
120    rtems_panic("cannot install decrementer exception handler");
121  }
122
123  /* Initalize interrupt support */
124  bsp_interrupt_initialize();
125
126#ifdef SHOW_MORE_INIT_SETTINGS
127  printk("Exit from bspstart\n");
128#endif
129}
Note: See TracBrowser for help on using the repository browser.