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

4.115
Last change on this file since 32ec0f6b was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

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