source: rtems/c/src/lib/libbsp/powerpc/mpc55xxevb/startup/bspstart.c @ ced11eb1

4.115
Last change on this file since ced11eb1 was ced11eb1, checked in by Sebastian Huber <sebastian.huber@…>, on 02/18/13 at 15:27:50

bsp/mpc55xx: Fix prototype

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc55xx
5 *
6 * @brief BSP startup code.
7 */
8
9/*
10 * Copyright (c) 2008-2011 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@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.com/license/LICENSE.
21 */
22
23#include <mpc55xx/mpc55xx.h>
24#include <mpc55xx/regs.h>
25#include <mpc55xx/edma.h>
26#include <mpc55xx/emios.h>
27
28#include <string.h>
29
30#include <rtems.h>
31#include <rtems/config.h>
32
33#include <libcpu/powerpc-utility.h>
34#include <bsp/vectors.h>
35
36#include <bsp.h>
37#include <bsp/bootcard.h>
38#include <bsp/irq.h>
39#include <bsp/irq-generic.h>
40#include <bsp/linker-symbols.h>
41#include <bsp/start.h>
42#include <bsp/mpc55xx-config.h>
43
44/* Symbols defined in linker command file */
45LINKER_SYMBOL(mpc55xx_exc_vector_base);
46
47unsigned int bsp_clock_speed = 0;
48
49uint32_t bsp_clicks_per_usec = 0;
50
51void _BSP_Fatal_error(unsigned n)
52{
53        rtems_interrupt_level level;
54
55        rtems_interrupt_disable( level);
56
57        while (true) {
58                mpc55xx_wait_for_interrupt();
59        }
60}
61
62void mpc55xx_fatal(mpc55xx_fatal_code code)
63{
64  rtems_fatal(RTEMS_FATAL_SOURCE_BSP_SPECIFIC, code);
65}
66
67static void null_pointer_protection(void)
68{
69#ifdef MPC55XX_NULL_POINTER_PROTECTION
70        struct MMU_tag mmu = { .MAS0 = { .B = { .TLBSEL = 1, .ESEL = 1 } } };
71
72        PPC_SET_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS0, mmu.MAS0.R);
73        __asm__ volatile ("tlbre");
74        mmu.MAS1.R = PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1);
75        mmu.MAS1.B.VALID = 0;
76        PPC_SET_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1, mmu.MAS1.R);
77        __asm__ volatile ("tlbwe");
78#endif
79}
80
81void bsp_start(void)
82{
83        ppc_cpu_id_t myCpu;
84        ppc_cpu_revision_t myCpuRevision;
85
86        null_pointer_protection();
87
88        /*
89         * make sure BSS/SBSS is cleared
90         */
91        memset(&bsp_section_bss_begin [0], 0, (size_t) bsp_section_bss_size);
92
93        /*
94         * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
95         * function store the result in global variables so that it can be used
96         * latter...
97         */
98        myCpu = get_ppc_cpu_type();
99        myCpuRevision = get_ppc_cpu_revision();
100
101        /*
102         * determine clock speed
103         */
104        bsp_clock_speed = mpc55xx_get_system_clock() / MPC55XX_SYSTEM_CLOCK_DIVIDER;
105
106        /* Time reference value */
107        bsp_clicks_per_usec = bsp_clock_speed / 1000000;
108
109        /* Initialize exceptions */
110        ppc_exc_vector_base = (uint32_t) mpc55xx_exc_vector_base;
111        ppc_exc_initialize(
112                PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
113                (uintptr_t) bsp_section_work_begin,
114                rtems_configuration_get_interrupt_stack_size()
115        );
116        #ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
117                ppc_exc_set_handler(ASM_ALIGN_VECTOR, ppc_exc_alignment_handler);
118        #endif
119
120        /* Initialize interrupts */
121        bsp_interrupt_initialize();
122
123        mpc55xx_edma_init();
124        #ifdef MPC55XX_EMIOS_PRESCALER
125                mpc55xx_emios_initialize(MPC55XX_EMIOS_PRESCALER);
126        #endif
127}
Note: See TracBrowser for help on using the repository browser.