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

4.115
Last change on this file since a762dc2 was a762dc2, checked in by Sebastian Huber <sebastian.huber@…>, on 01/23/12 at 10:19:22

Support for MPC5643L.

Rework of the start sequence to reduce the amount assembler code and to
support configuration tables which may be provided by the application.

  • Property mode set to 100644
File size: 3.5 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 * $Id$
23 */
24
25#include <mpc55xx/mpc55xx.h>
26#include <mpc55xx/regs.h>
27#include <mpc55xx/edma.h>
28#include <mpc55xx/emios.h>
29
30#include <string.h>
31
32#include <rtems.h>
33#include <rtems/config.h>
34
35#include <libcpu/powerpc-utility.h>
36#include <bsp/vectors.h>
37
38#include <bsp.h>
39#include <bsp/bootcard.h>
40#include <bsp/irq.h>
41#include <bsp/irq-generic.h>
42#include <bsp/linker-symbols.h>
43#include <bsp/start.h>
44#include <bsp/mpc55xx-config.h>
45
46extern Heap_Control *RTEMS_Malloc_Heap;
47
48/* Symbols defined in linker command file */
49LINKER_SYMBOL(mpc55xx_exc_vector_base);
50
51unsigned int bsp_clock_speed = 0;
52
53uint32_t bsp_clicks_per_usec = 0;
54
55void BSP_panic( char *s)
56{
57        rtems_interrupt_level level;
58
59        rtems_interrupt_disable( level);
60
61        printk( "%s PANIC %s\n", _RTEMS_version, 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
74        printk( "%s PANIC ERROR %u\n", _RTEMS_version, n);
75
76        while (1) {
77                /* Do nothing */
78        }
79}
80
81static void null_pointer_protection(void)
82{
83#if defined(MPC55XX_BOARD_MPC5674FEVB) || defined(MPC55XX_BOARD_MPC5566EVB)
84        struct MMU_tag mmu = { .MAS0 = { .B = { .TLBSEL = 1, .ESEL = 1 } } };
85
86        PPC_SET_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS0, mmu.MAS0.R);
87        __asm__ volatile ("tlbre");
88        mmu.MAS1.R = PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1);
89        mmu.MAS1.B.VALID = 0;
90        PPC_SET_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1, mmu.MAS1.R);
91        __asm__ volatile ("tlbwe");
92#endif
93}
94
95void bsp_start(void)
96{
97        rtems_status_code sc = RTEMS_SUCCESSFUL;
98        ppc_cpu_id_t myCpu;
99        ppc_cpu_revision_t myCpuRevision;
100#if defined(MPC55XX_BOARD_MPC5674FEVB)
101        unsigned system_clock_divider = 2;
102#else
103        unsigned system_clock_divider = 1;
104#endif
105
106        null_pointer_protection();
107
108        /*
109         * make sure BSS/SBSS is cleared
110         */
111        memset(&bsp_section_bss_begin [0], 0, (size_t) bsp_section_bss_size);
112
113        /*
114         * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
115         * function store the result in global variables so that it can be used
116         * latter...
117         */
118        myCpu = get_ppc_cpu_type();
119        myCpuRevision = get_ppc_cpu_revision();
120
121        /*
122         * determine clock speed
123         */
124        bsp_clock_speed = mpc55xx_get_system_clock() / system_clock_divider;
125
126        /* Time reference value */
127        bsp_clicks_per_usec = bsp_clock_speed / 1000000;
128
129        /* Initialize exceptions */
130        ppc_exc_vector_base = (uint32_t) mpc55xx_exc_vector_base;
131        sc = ppc_exc_initialize(
132                PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
133                (uintptr_t) bsp_section_work_begin,
134                Configuration.interrupt_stack_size
135        );
136        if (sc != RTEMS_SUCCESSFUL) {
137                BSP_panic( "Cannot initialize exceptions");
138        }
139        ppc_exc_set_handler(ASM_ALIGN_VECTOR, ppc_exc_alignment_handler);
140
141        /* Initialize interrupts */
142        sc = bsp_interrupt_initialize();
143        if (sc != RTEMS_SUCCESSFUL) {
144                BSP_panic( "Cannot initialize interrupts");
145        }
146
147        mpc55xx_edma_init();
148        #ifdef MPC55XX_EMIOS_PRESCALER
149                mpc55xx_emios_initialize(MPC55XX_EMIOS_PRESCALER);
150        #endif
151}
152
153void bsp_pretasking_hook(void)
154{
155        #if MPC55XX_CHIP_TYPE / 10 == 564
156                _Heap_Extend(
157                        RTEMS_Malloc_Heap,
158                        bsp_section_rwextra_end,
159                        (uintptr_t) bsp_ram_end
160                                - (uintptr_t) bsp_section_rwextra_end,
161                        NULL
162                );
163        #endif
164}
Note: See TracBrowser for help on using the repository browser.