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

4.115
Last change on this file since 6ec438e was 6ec438e, checked in by Sebastian Huber <sebastian.huber@…>, on 10/07/14 at 06:29:16

libchip/serial: Add alternative NS16550 driver

Use the Termios device API.

  • 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-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_panic(char *s)
55{
56  rtems_interrupt_level level;
57
58  rtems_interrupt_disable(level);
59  (void) level;
60
61  printk("%s PANIC %s\n", rtems_get_version_string(), s);
62
63  while (1) {
64    /* Do nothing */
65  }
66}
67
68void _BSP_Fatal_error(unsigned n)
69{
70  rtems_interrupt_level level;
71
72  rtems_interrupt_disable( level);
73  (void) level;
74
75  printk( "%s PANIC ERROR %u\n", rtems_get_version_string(), n);
76
77  while (1) {
78    /* Do nothing */
79  }
80}
81
82void bsp_start( void)
83{
84  rtems_status_code sc = RTEMS_SUCCESSFUL;
85  unsigned long i = 0;
86
87  /*
88   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
89   * store the result in global variables so that it can be used latter...
90   */
91  get_ppc_cpu_type();
92  get_ppc_cpu_revision();
93
94  /* Basic CPU initialization */
95  cpu_init();
96
97  /*
98   * Enable instruction and data caches. Do not force writethrough mode.
99   */
100
101#ifdef BSP_INSTRUCTION_CACHE_ENABLED
102  rtems_cache_enable_instruction();
103#endif
104
105#ifdef BSP_DATA_CACHE_ENABLED
106  rtems_cache_enable_data();
107#endif
108
109  /*
110   * This is evaluated during runtime, so it should be ok to set it
111   * before we initialize the drivers.
112   */
113
114  /* Initialize some device driver parameters */
115
116#ifdef HAS_UBOOT
117  BSP_bus_frequency = bsp_uboot_board_info.bi_busfreq;
118#else /* HAS_UBOOT */
119  BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
120#endif /* HAS_UBOOT */
121  bsp_time_base_frequency = BSP_bus_frequency / 4;
122  bsp_clicks_per_usec = bsp_time_base_frequency / 1000000;
123  rtems_counter_initialize_converter(bsp_time_base_frequency);
124
125  /* Initialize some console parameters */
126  for (i = 0; i < console_device_count; ++i) {
127    ns16550_context *ctx = (ns16550_context *) console_device_table[i].context;
128
129    ctx->clock = BSP_bus_frequency;
130
131    #ifdef HAS_UBOOT
132      ctx->initial_baud = bsp_uboot_board_info.bi_baudrate;
133    #endif
134  }
135
136  /* Initialize exception handler */
137#ifndef BSP_DATA_CACHE_ENABLED
138  ppc_exc_cache_wb_check = 0;
139#endif
140  ppc_exc_initialize(
141    (uintptr_t) bsp_section_work_begin,
142    rtems_configuration_get_interrupt_stack_size()
143  );
144
145  /* Install default handler for the decrementer exception */
146  sc = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler);
147  if (sc != RTEMS_SUCCESSFUL) {
148    BSP_panic("cannot install decrementer exception handler");
149  }
150
151  /* Initalize interrupt support */
152  bsp_interrupt_initialize();
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.